ssg.ts#
31 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
fnbuildSsg(options: ResolvedOptions, root: string): Promise<SsgBuildResult>Builds all markdown files to static HTML.
Builds all markdown files to static HTML.
Signature
export async function buildSsg(options: ResolvedOptions, root: string): Promise<SsgBuildResult>Parameters
-
optionsResolvedOptions -
rootstring
Returns
Promise<SsgBuildResult>
fncanonicalPageUrl(context: BuildSsgContext, urlPath: string): string | undefinedAbsolute URL of a page, or undefined when ssg.siteUrl is not set. Built the sam…
Absolute URL of a page, or undefined when ssg.siteUrl is not set.
Built the same way get_og_image_url builds the image URL next to it, so the canonical link and og:image always agree about where the page lives.
Signature
function canonicalPageUrl(context: BuildSsgContext, urlPath: string): string | undefinedParameters
-
contextBuildSsgContext -
urlPathstring
Returns
string | undefined
fncollectMarkdownFiles(srcDir: string, extensions: readonly string[] = DEFAULT_MARKDOWN_EXTENSIONS): Promise<string[]>Collects all markdown files from the source directory.
Collects all markdown files from the source directory.
Signature
export async function collectMarkdownFiles(srcDir: string, extensions: readonly string[] = DEFAULT_MARKDOWN_EXTENSIONS): Promise<string[]>Parameters
-
srcDirstring -
extensionsreadonly string[]optional · default: DEFAULTMARKDOWNEXTENSIONS
Returns
Promise<string[]>
variableconst DEFAULT_HTML_TEMPLATE = "<!-- ox-content default HTML template is Rust-backed -->"Deprecated compatibility export for consumers that imported the former TypeScri…
Deprecated compatibility export for consumers that imported the former TypeScript SSG template. HTML generation is Rust-backed now.
Signature
export const DEFAULT_HTML_TEMPLATE = "<!-- ox-content default HTML template is Rust-backed -->"fnextractTitle(content: string, frontmatter: Record<string, unknown>): stringExtracts title from content or frontmatter.
Extracts title from content or frontmatter.
Signature
export function extractTitle(content: string, frontmatter: Record<string, unknown>): stringParameters
-
contentstring -
frontmatterRecord<string, unknown>
Returns
string
fnformatTitle(name: string): stringFormats a file/dir name as a title.
Formats a file/dir name as a title.
Signature
export function formatTitle(name: string): stringParameters
-
namestring
Returns
string
fngenerateBareHtmlPage(content: string, title: string): stringGenerates bare HTML page (no navigation, no styles).
Generates bare HTML page (no navigation, no styles).
Signature
export function generateBareHtmlPage(content: string, title: string): stringParameters
-
contentstring -
titlestring
Returns
string
fngenerateBarePage(page: SsgBarePage): stringGenerates a bare HTML page carrying head metadata and injected markup. Bare mod…
Generates a bare HTML page carrying head metadata and injected markup.
Bare mode leaves the shell to the consumer, but the metadata here is already computed for the themed page and cannot be recovered afterwards — the generated OG image in particular was only discoverable by guessing at the output directory. A page with none of it set renders exactly what bare mode emitted before, which keeps the no-JS size baseline honest.
Signature
export function generateBarePage(page: SsgBarePage): stringParameters
-
pageSsgBarePage
Returns
string
fngenerateHtmlPage(pageData: SsgPageData, navGroups: NavGroup[], siteName: string, base: string, ogImage?: string, theme?: ResolvedThemeConfig, locale?: string, availableLocales?: LocaleConfig[]): Promise<string>Generates HTML page with navigation using Rust NAPI bindings.
Generates HTML page with navigation using Rust NAPI bindings.
Signature
export async function generateHtmlPage(pageData: SsgPageData, navGroups: NavGroup[], siteName: string, base: string, ogImage?: string, theme?: ResolvedThemeConfig, locale?: string, availableLocales?: LocaleConfig[]): Promise<string>Parameters
-
pageDataSsgPageData -
navGroupsNavGroup[] -
siteNamestring -
basestring -
ogImagestringoptional
-
themeResolvedThemeConfigoptional
-
localestringoptional
-
availableLocalesLocaleConfig[]optional
Returns
Promise<string>
fngetHref(inputPath: string, srcDir: string, base: string, extension: string): stringConverts a markdown file path to an href.
Converts a markdown file path to an href.
Signature
export function getHref(inputPath: string, srcDir: string, base: string, extension: string): stringParameters
-
inputPathstring -
srcDirstring -
basestring -
extensionstring
Returns
string
fngetOutputPath(inputPath: string, srcDir: string, outDir: string, extension: string): stringConverts a markdown file path to its corresponding HTML output path.
Converts a markdown file path to its corresponding HTML output path.
Signature
export function getOutputPath(inputPath: string, srcDir: string, outDir: string, extension: string): stringParameters
-
inputPathstring -
srcDirstring -
outDirstring -
extensionstring
Returns
string
fngetUrlPath(inputPath: string, srcDir: string): stringConverts a markdown file path to a relative URL path.
Converts a markdown file path to a relative URL path.
Signature
export function getUrlPath(inputPath: string, srcDir: string): stringParameters
-
inputPathstring -
srcDirstring
Returns
string
variableconst localeCodesCache = new WeakMap<LocaleConfig[], string[]>()Per-build cache for the locale-code list passed to getSsgPageLocale. The i18n.l…
Per-build cache for the locale-code list passed to getSsgPageLocale. The i18n.locales reference is stable across a build, so the .map to codes runs once instead of once per page.
Signature
const localeCodesCache = new WeakMap<LocaleConfig[], string[]>()fnresolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptionsResolves SSG options with defaults.
Resolves SSG options with defaults.
Signature
export function resolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptionsParameters
-
ssgSsgOptions | boolean | undefined
Returns
interfaceRustLocaleRust-facing locale shape.
Rust-facing locale shape.
Signature
interface RustLocaleMembers
Properties
| Name | Type | Description |
|---|---|---|
code |
string |
|
dir |
string |
|
name |
string |
variableconst rustLocalesCache = new WeakMap<LocaleConfig[], RustLocale[]>()Per-build cache for the Rust-facing locale list. i18n.locales is the same refer…
Per-build cache for the Rust-facing locale list. i18n.locales is the same reference for every page in a build, so this mapping (and the ?? "ltr" default) only runs once per build instead of once per page.
Signature
const rustLocalesCache = new WeakMap<LocaleConfig[], RustLocale[]>()fnshouldGenerateOgImages(options: ResolvedOptions): booleanWhether this build emits one Open Graph image per page. ssg.bare deliberately d…
Whether this build emits one Open Graph image per page.
ssg.bare deliberately does not turn this off. Bare mode only drops the generated page shell, and bringing your own shell is exactly the case where per-page OG images are still wanted — the images are written to the output tree and the consumer injects the <meta> tags itself. Nothing in the bare HTML references them, because bare output has no <head> to put them in.
Signature
export function shouldGenerateOgImages(options: ResolvedOptions): booleanParameters
-
optionsResolvedOptions
Returns
boolean
modulessgSSG (Static Site Generation) module for ox-content
SSG (Static Site Generation) module for ox-content
interfaceSsgBarePageHead metadata and injected markup for a bare page.
Head metadata and injected markup for a bare page.
Signature
export interface SsgBarePageMembers
Properties
| Name | Type | Description |
|---|---|---|
bodyEndoptional |
string |
|
bodyStartoptional |
string |
|
canonicalUrloptional |
string |
|
content |
string |
|
descriptionoptional |
string |
|
diroptional |
string |
|
headoptional |
string |
|
langoptional |
string |
|
ogImageoptional |
string |
|
siteNameoptional |
string |
|
title |
string |
interfaceSsgBuildResultResult of an SSG build.
Result of an SSG build.
Signature
export interface SsgBuildResultMembers
Properties
| Name | Type | Description |
|---|---|---|
errors |
string[] |
Per-page failures that did not abort the build. |
files |
string[] |
Every file written, HTML pages and generated OG images alike. |
ogImages |
Record<string, string> |
Generated OG image URL per source file, keyed by absolute input path. Bare mode renders these into the page itself, but a consumer post-processing the output had no way to find them short of probing the output directory for og-image.png. |
interfaceSsgEntryPageConfigEntry page configuration for SSG (passed to Rust).
Entry page configuration for SSG (passed to Rust).
Signature
export interface SsgEntryPageConfigMembers
Properties
| Name | Type | Description |
|---|---|---|
featuresoptional |
FeatureConfig[] |
|
herooptional |
HeroConfig |
interfaceSsgPageDataPage data for SSG.
Page data for SSG.
Signature
export interface SsgPageDataMembers
Properties
| Name | Type | Description |
|---|---|---|
content |
string |
|
descriptionoptional |
string |
|
entryPageoptional |
SsgEntryPageConfig |
Entry page configuration (if layout: entry) |
frontmatter |
Record<string, unknown> |
|
href |
string |
|
lastUpdatedoptional |
number |
|
path |
string |
|
title |
string |
|
toc |
TocEntry[] |
fntoRustTocEntry(entry: TocEntry): TocEntryConverts a TocEntry tree into the plain shape the Rust binding expects. Hoisted…
Converts a TocEntry tree into the plain shape the Rust binding expects. Hoisted to module scope so it isn't reallocated for every page; the per-page .map over pageData.toc still runs since the TOC is page-specific.
Signature
function toRustTocEntry(entry: TocEntry): TocEntryParameters
-
entryTocEntry
Returns
fntoThemePageData(pageResult: PageProcessResult): ThemePageDataMaps an internal page result onto the theme renderer's page shape.
Maps an internal page result onto the theme renderer's page shape.
Signature
function toThemePageData(pageResult: PageProcessResult): ThemePageDataParameters
-
pageResultPageProcessResult
Returns
ThemePageData