hyogen-md

0.10.0

build

Generates rendered Markdown files for many entries at once. Designed for SSG workflows.

import { build } from '@b4moss/hyogen-md'

function build(options: BuildOptions): Promise<BuildResult>

Options

type BuildOptions = RenderOptions & {
  input: string | string[]   // file paths or globs
  outDir: string             // output directory
  includeUnderscoreEntries?: boolean
  context?: HyogenContext
  serverContext?: HyogenContext
}
OptionDefaultDescription
inputOne or more entry paths or globs (Vite-style, via picomatch / fast-glob)
outDirDirectory for rendered .md files
context{}Shared template context for all entries
serverContextServer-only context merged per entry
includeUnderscoreEntriesfalseInclude _ partial files as build entries
loadercreateNodeLoader()Custom loader
rootautoProject root (.doc_root marker)
preserveFrontMatterfalseKeep YAML front matter in output
preserveHgCommentsfalseKeep <!-- @hg --> comments in output

Entry discovery

By default, build:

  1. Matches input globs
  2. Filters out _ partials (files or paths under _ directories) unless includeUnderscoreEntries is true
  3. Walks include / component / extend dependencies from each entry

Explicitly listed paths in input override the _ partial filter.

Example

import { build } from '@b4moss/hyogen-md'

const { files, warnings } = await build({
  input: 'content/**/*.md',
  outDir: 'dist/content',
  context: { siteName: 'My Docs' },
  serverContext: { buildTime: Date.now() },
})

for (const file of files) {
  console.log(file.path, file.markdown.length)
}

Return value

type BuildResult = {
  files: { path: string; markdown: string }[]
  warnings: HyogenWarning[]
}

Files are also written to outDir. The files array lets you consume output in-process without reading disk.