ssg.ts

Source

25 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

25 symbols 14 functions 6 interfaces 4 variables 1 modules 39 parameters 28 members 14 returns 1 deprecated

Reference

fnbuildNavItems(markdownFiles: string[], srcDir: string, base: string, extension: string): NavGroup[]Builds navigation items from markdown files, grouped by directory.

Builds navigation items from markdown files, grouped by directory.

Signature

export function buildNavItems(markdownFiles: string[], srcDir: string, base: string, extension: string): NavGroup[]

View source

Parameters

  • markdownFiles string[]
  • srcDir string
  • base string
  • extension string

Returns

NavGroup[]
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[] }>

View source

Parameters

Returns

Promise<{ files: string[]; errors: string[] }>
fnbuildThemeNavItems(sidebar: SidebarItem[], base: string, extension: string): NavGroup[]Builds navigation items from an explicit theme sidebar tree.

Builds navigation items from an explicit theme sidebar tree.

Signature

export function buildThemeNavItems(sidebar: SidebarItem[], base: string, extension: string): NavGroup[]

View source

Parameters

  • sidebar SidebarItem[]
  • base string
  • extension string

Returns

NavGroup[]
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[]>

View source

Parameters

  • srcDir string
  • extensions readonly 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 -->"

View source

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

View source

Parameters

  • content string
  • frontmatter Record<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

View source

Parameters

  • name string

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

View source

Parameters

  • content string
  • title string

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>

View source

Parameters

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

View source

Parameters

  • inputPath string
  • srcDir string
  • base string
  • extension string

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

View source

Parameters

  • inputPath string
  • srcDir string
  • outDir string
  • extension string

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

View source

Parameters

  • inputPath string
  • srcDir string

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[]>()

View source

interfaceNavGroupNavigation group for hierarchical navigation.

Navigation group for hierarchical navigation.

Signature

export interface NavGroup

View source

Members

Properties
NameTypeDescription
variableconst navGroupsForRustCache = new WeakMap<NavGroup[], RustNavGroup[]>()Per-build cache for the Rust-facing nav conversion. navGroups is the same conte…

Per-build cache for the Rust-facing nav conversion. navGroups is the same context.navItems reference for every page in a build, so the deep recursive copy below only needs to run once per build instead of once per page.

Signature

const navGroupsForRustCache = new WeakMap<NavGroup[], RustNavGroup[]>()

View source

fnresolveNavigationGroups(navigation: SsgNavigationGroup[] | undefined, base: string, extension: string): NavGroup[] | undefinedResolves manual navigation config to the format used by the built-in SSG render…

Resolves manual navigation config to the format used by the built-in SSG renderer.

Signature

export function resolveNavigationGroups(navigation: SsgNavigationGroup[] | undefined, base: string, extension: string): NavGroup[] | undefined

View source

Parameters

Returns

NavGroup[] | undefined
fnresolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptionsResolves SSG options with defaults.

Resolves SSG options with defaults.

Signature

export function resolveSsgOptions(ssg: SsgOptions | boolean | undefined): ResolvedSsgOptions

View source

Parameters

Returns

ResolvedSsgOptions
interfaceRustLocaleRust-facing locale shape.

Rust-facing locale shape.

Signature

interface RustLocale

View source

Members

Properties
NameTypeDescription
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[]>()

View source

interfaceRustNavGroupNAPI-facing nav group shape produced from a NavGroup.

NAPI-facing nav group shape produced from a [NavGroup].

Signature

interface RustNavGroup

View source

Members

Properties
NameTypeDescription
collapsedoptional boolean
items SsgNavItem[]
stickyCollapsedoptional boolean
title string
modulessgSSG (Static Site Generation) module for ox-content

SSG (Static Site Generation) module for ox-content

View source

interfaceSsgEntryPageConfigEntry page configuration for SSG (passed to Rust).

Entry page configuration for SSG (passed to Rust).

Signature

export interface SsgEntryPageConfig

View source

Members

Properties
NameTypeDescription
featuresoptional FeatureConfig[]
herooptional HeroConfig
interfaceSsgNavItemNavigation item for SSG.

Navigation item for SSG.

Signature

export interface SsgNavItem

View source

Members

Properties
NameTypeDescription
childrenoptional SsgNavItem[]
collapsedoptional boolean
href string
path string
stickyCollapsedoptional boolean
title string
interfaceSsgPageDataPage data for SSG.

Page data for SSG.

Signature

export interface SsgPageData

View source

Members

Properties
NameTypeDescription
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

View source

Parameters

Returns

TocEntry