ssg.ts
25 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference
fnbuildSsg(options: ResolvedOptions, root: string): Promise<{ files: string[]; errors: string[] }>Builds all markdown files to static HTML.
Builds all markdown files to static HTML.
Signature
export async function buildSsg(options: ResolvedOptions, root: string): Promise<{ files: string[]; errors: string[] }>
Parameters
-
optionsResolvedOptions -
rootstring
Returns
Promise<{ files: string[]; errors: string[] }>
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>): string
Parameters
-
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): string
Parameters
-
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): string
Parameters
-
contentstring -
titlestring
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): string
Parameters
-
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): string
Parameters
-
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): string
Parameters
-
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): ResolvedSsgOptions
Parameters
-
ssgSsgOptions | boolean | undefined
Returns
interfaceRustLocaleRust-facing locale shape.
Rust-facing locale shape.
Signature
interface RustLocale
Members
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[]>()
modulessgSSG (Static Site Generation) module for ox-content
SSG (Static Site Generation) module for ox-content
interfaceSsgEntryPageConfigEntry page configuration for SSG (passed to Rust).
Entry page configuration for SSG (passed to Rust).
Signature
export interface SsgEntryPageConfig
Members
Properties
| Name | Type | Description |
|---|---|---|
featuresoptional |
FeatureConfig[] |
|
herooptional |
HeroConfig |
interfaceSsgPageDataPage data for SSG.
Page data for SSG.
Signature
export interface SsgPageData
Members
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): TocEntry
Parameters
-
entryTocEntry