Ox Content

API Documentation

Generated by Ox Content

Modules

dev-server

  • function shouldSkip - Check if a request URL should be skipped by the dev server middleware.

  • function resolveMarkdownFile - Resolve a request URL to a markdown file path.

Returns null if no matching file ...

  • function injectViteHmrClient - Inject Vite HMR client script into the HTML.

  • interface DevServerCache - Dev server state for caching.

  • function createDevServerCache - Create a dev server cache instance.

  • function invalidateNavCache - Invalidate navigation cache (called on file add/unlink).

  • function invalidatePageCache - Invalidate page cache for a specific file (called on file change).

  • function resolveSiteName - Resolve site name from options or package.json.

  • function renderPage - Render a single markdown page to full HTML.

  • function createDevServerMiddleware - Create the dev server middleware for SSG page serving.

docs

  • function extractDocs - Extracts JSDoc documentation from source files in specified directories.

This fu...

  • function findFiles - Recursively finds all source files matching include/exclude patterns.

  • function extractFromContent - Extracts documentation entries from file content.

  • function extractFunctionSignature - Extracts the complete function signature for display.

Captures the full function...

  • function extractTypesFromSignature - Extracts parameter and return types from a TypeScript function signature.

Parses...

  • function splitParameters - Splits function parameters while respecting nested angle brackets (generics).

Ha...

  • function parseJsdocBlock - Parses a JSDoc block and the following declaration.

Only matches if the declarat...

  • function generateMarkdown - Generates Markdown documentation from extracted docs.

  • interface SymbolLocation - Symbol location info for cross-file linking.

  • function convertSymbolLinks - Converts symbol links [SymbolName] to markdown links.

Processes description text...

  • function buildSymbolMap - Builds a map of all symbols to their file locations.

  • function writeDocs - Writes generated documentation to the output directory.

  • function generateSourceLink - Generates a GitHub source link for a file and optional line number.

environment

  • function createMarkdownEnvironment - Creates the Markdown processing environment configuration.

This environment is u...

  • interface EnvironmentTransformContext - Environment-specific module transformer.

This is called during the transform pha...

  • function createTransformOptions - Creates environment-aware transform options.

  • function prerender - Runs pre-render for SSG.

This function is called during build to pre-render all ...

  • function createEnvironmentPlugins - Environment plugin factory.

Creates plugins specific to the Markdown environment...

highlight

  • function getHighlighter - Get or create the Shiki highlighter.

  • function rehypeShikiHighlight - Rehype plugin for syntax highlighting with Shiki.

  • function getTextContent - Extract text content from a hast node.

  • function highlightCode - Apply syntax highlighting to HTML using Shiki.

i18n

  • function resolveI18nOptions - Resolves i18n options with defaults.

  • function createI18nPlugin - Creates the i18n sub-plugin for the Vite plugin array.

  • function generateI18nModule - Generates the virtual module for i18n configuration.

  • function flattenObject - Flattens a nested object into dot-separated keys.

  • function loadDictionariesFallback - Fallback dictionary loading using TS-based JSON file reading.

  • function collectKeysFromSource - Collects translation keys from source files using NAPI extractTranslationKeys.

  • function walkDir - Recursively walks a directory, calling the callback for files matching the patte...

index

  • function oxContent - Creates the Ox Content Vite plugin.

  • function resolveOptions - Resolves plugin options with defaults.

  • function generateVirtualModule - Generates virtual module content.

parse

  • function getAttribute - Get element attribute value.

  • function parseProps - Parse JSX-style props from attributes.

  • function findComponentElement - Find the component element inside <Island>.

  • function getComponentName - Get component name from child element.

  • function resetIslandCounter - Reset island counter (for testing).

  • function rehypeIslands - Rehype plugin to transform Island components.

  • function transformIslands - Transform Island components in HTML.

Converts:

<Island load="visible">
<...
- `function` **hasIslands** - Check if HTML contains any Island components.
- `function` **extractIslandInfo** - Extract island info without transforming HTML.
Useful for analysis/bundling purp...
- `function` **generateHydrationScript** - Generate client-side hydration script.
This is a minimal script that imports and...

### [jsx-runtime](./jsx-runtime.md)

- `function` **escapeHtml** - Escapes HTML special characters to prevent XSS.
- `function` **toHtmlAttr** - Converts a camelCase attribute name to kebab-case for HTML.
Special handling for...
- `function` **renderAttr** - Renders an attribute value to a string.
- `type` **JSXElementType** - JSX element type - either a string (intrinsic) or a function component.
- `type` **JSXChild** - Valid JSX child types.
- `interface` **JSXNode** - JSX node - the result of JSX expressions.
- `interface` **JSXProps** - Props with children.
- `function` **renderChildren** - Renders children to HTML string.
- `function` **jsx** - Creates a JSX element.
This is the core function called by the JSX transform.
- `function` **jsxs** - Creates a JSX element with static children.
Called by the JSX transform for elem...
- `function` **Fragment** - Fragment component - renders children without a wrapper element.
- `function` **renderToString** - Renders a JSX node to an HTML string.
- `function` **raw** - Creates raw HTML without escaping.
Use with caution - only for trusted content.
- `function` **when** - Conditionally renders content.
- `function` **each** - Maps over an array and renders each item.

### [jsx.d](./jsx.d.md)

- `type` **Element** - The type returned by JSX expressions.
- `interface` **IntrinsicElements** - Props for intrinsic elements (HTML tags).
- `interface` **HTMLAttributes** - Base HTML attributes shared by all elements.
- `type` **IntrinsicElementType** - Type for intrinsic element constructors.
- `type` **IntrinsicElementProps** - Props for a specific intrinsic element.

### [nav-generator](./nav-generator.md)

- `function` **generateNavMetadata** - Generates sidebar navigation metadata from extracted documentation.
Takes an arr...
- `function` **getDocDisplayName** - Gets the human-readable display name for a documentation file.
Transforms file p...
- `function` **getDocFileName** - Gets the file name (without extension) for use in navigation paths.
This handles...
- `function` **generateNavCode** - Generates TypeScript code for navigation metadata export.
Creates a complete, se...

### [browser](./browser.md)

- `interface` **OgBrowserSession** - A browser session that can render HTML pages to PNG.
Implements AsyncDisposable ...
- `function` **openBrowser** - Opens a Chromium browser and returns a session for rendering OG images.
Returns ...

### [cache](./cache.md)

- `function` **computeCacheKey** - Computes a cache key from template + props + options.
- `function` **getCached** - Checks if a cached PNG exists for the given key.
Returns the cached file path if...
- `function` **writeCache** - Writes a PNG buffer to the cache.

### [index](./index-module.md)

- `function` **resolveOgImageOptions** - Resolves user-provided OG image options with defaults.
- `interface` **OgImagePageEntry** - A single page entry for batch OG image generation.
- `interface` **OgImageResult** - Result of OG image generation for a single page.
- `function` **resolveTemplate** - Resolves the template function from options.
Dispatches by file extension:
- `.v...
- `function` **resolveTsTemplate** - Resolves a plain TypeScript template (existing behavior).
- `function` **resolveVueTemplate** - Resolves a Vue SFC template via SSR.
Compiles the SFC with @vue/compiler-sfc (or...
- `function` **createVueCompilerPlugin** - Creates a rolldown plugin that compiles Vue SFCs using @vue/compiler-sfc.
- `function` **getVizejsPlugin** - Loads @vizejs/vite-plugin as a rolldown plugin for Vue SFC compilation.
- `function` **resolveSvelteTemplate** - Resolves a Svelte SFC template via SSR.
Compiles the SFC with svelte/compiler (s...
- `function` **createSvelteCompilerPlugin** - Creates a rolldown plugin that compiles Svelte SFCs using svelte/compiler.
- `function` **resolveReactTemplate** - Resolves a React (.tsx/.jsx) template via SSR.
Bundles with rolldown (JSX transf...
- `function` **computeTemplateSource** - Computes a stable template source identifier for cache keys.
For custom template...
- `function` **generateOgImages** - Generates OG images for a batch of pages.
Manages the full lifecycle: resolve te...
- `function` **tryServeAllFromCache** - Tries to serve all pages from cache.
Returns results if ALL pages are cached, nu...
- `function` **renderSinglePage** - Renders a single page to PNG, with cache support.

### [renderer](./renderer.md)

- `function` **wrapHtml** - Wraps template HTML in a minimal document with viewport locked to given dimensio...
- `function` **renderHtmlToPng** - Renders an HTML string to a PNG buffer using Chromium.

### [template](./template.md)

- `function` **escapeHtml** - Escapes HTML special characters.
- `function` **getDefaultTemplate** - Returns the built-in default template function.

### [types](./types.md)

- `interface` **OgImageTemplateProps** - Props passed to OG image template functions.
- `type` **OgImageTemplateFn** - Template function that receives page metadata and returns an HTML string.
- `interface` **OgImageOptions** - OG image generation options (user-facing).
- `interface` **ResolvedOgImageOptions** - Resolved OG image options with all defaults applied.

### [page-context](./page-context.md)

- `interface` **BasePageProps** - Base page props available for all pages.
- `type` **PageProps** - Extended page props with custom frontmatter.
- `interface` **SiteConfig** - Site-wide configuration available in context.
- `interface` **NavGroup** - Navigation group.
- `interface` **NavItem** - Navigation item.
- `interface` **RenderContext** - Complete render context.
- `function` **setRenderContext** - Sets the current render context.
Called internally during page rendering.
- `function` **clearRenderContext** - Clears the current render context.
Called internally after page rendering.
- `function` **usePageProps** - Gets the current page props.
- `function` **useSiteConfig** - Gets the site configuration.
- `function` **useRenderContext** - Gets the full render context.
- `function` **useNav** - Gets the navigation groups.
- `function` **useIsActive** - Checks if the given path is the current page.
- `interface` **FrontmatterSchema** - Schema for frontmatter type generation.
- `function` **inferType** - Infers TypeScript types from frontmatter values.
- `function` **generateFrontmatterTypes** - Generates TypeScript interface from frontmatter samples.

### [github](./github.md)

- `function` **getAttribute** - Get element attribute value.
- `function` **formatNumber** - Format number with K/M suffix.
- `function` **fetchRepoData** - Fetch repository data from GitHub API.
- `function` **createGitHubCard** - Create GitHub card element from repo data.
- `function` **createFallbackCard** - Create fallback element when repo data is unavailable.
- `function` **collectGitHubRepos** - Collect all GitHub repos from HTML for pre-fetching.
- `function` **prefetchGitHubRepos** - Pre-fetch all GitHub repos data.
- `function` **rehypeGitHub** - Rehype plugin to transform GitHub components.
- `function` **transformGitHub** - Transform GitHub components in HTML.

### [index](./index-module.md)

- `interface` **TransformAllOptions** - Transform all plugin components in HTML.
Call this during SSG build to process a...
- `function` **transformAllPlugins** - Transform all enabled plugins in HTML content.

### [mermaid-protect](./mermaid-protect.md)

- `interface` **MermaidSvgProtection** - Protects mermaid SVG content from rehype HTML5 parser corruption.
rehypeParse + ...
- `function` **protectMermaidSvgs** - Extract `<div class="ox-mermaid">...</div>` blocks and replace
with HTML comment...
- `function` **restoreMermaidSvgs** - Restore protected mermaid SVG blocks from placeholders.

### [mermaid](./mermaid.md)

- `function` **transformMermaidStatic** - Transforms mermaid code blocks in HTML to rendered SVG diagrams.
Uses the native...

### [ogp](./ogp.md)

- `function` **getAttribute** - Get element attribute value.
- `function` **extractDomain** - Extract domain from URL.
- `function` **getFaviconUrl** - Get favicon URL for a domain.
- `function` **parseOgpFromHtml** - Parse OGP metadata from HTML.
- `function` **fetchOgpData** - Fetch OGP data for a URL.
- `function` **createOgpCard** - Create OGP card element.
- `function` **createFallbackCard** - Create fallback element when OGP data is unavailable.
- `function` **collectOgpUrls** - Collect all OGP URLs from HTML for pre-fetching.
- `function` **prefetchOgpData** - Pre-fetch all OGP data.
- `function` **rehypeOgp** - Rehype plugin to transform OgCard components.
- `function` **transformOgp** - Transform OgCard components in HTML.

### [tabs](./tabs.md)

- `function` **resetTabGroupCounter** - Reset tab group counter (for testing).
- `function` **getAttribute** - Get element attribute value.
- `function` **parseTabChildren** - Parse Tab elements from Tabs children.
- `function` **createTabsElement** - Create the HTML structure for tabs.
- `function` **createFallbackElement** - Create fallback HTML using <details> elements.
- `function` **rehypeTabs** - Rehype plugin to transform Tabs components.
- `function` **transformTabs** - Transform Tabs components in HTML.
- `function` **generateTabsCSS** - Generate dynamic CSS for :has() based tab switching.
This is needed because :has...

### [youtube](./youtube.md)

- `function` **getAttribute** - Get element attribute value.
- `function` **extractVideoId** - Extract YouTube video ID from various URL formats.
- `function` **buildEmbedUrl** - Build YouTube embed URL with parameters.
- `function` **createYouTubeElement** - Create YouTube embed element.
- `function` **rehypeYouTube** - Rehype plugin to transform YouTube components.
- `function` **transformYouTube** - Transform YouTube components in HTML.

### [search](./search.md)

- `function` **resolveSearchOptions** - Resolves search options with defaults.
- `function` **collectMarkdownFiles** - Collects all Markdown files from a directory.
- `function` **buildSearchIndex** - Builds the search index from Markdown files.
- `function` **writeSearchIndex** - Writes the search index to a file.
- `function` **generateSearchModule** - Client-side search module code.
This is injected into the bundle as a virtual mo...

### [ssg](./ssg.md)

- `interface` **SsgNavItem** - Navigation item for SSG.
- `interface` **SsgEntryPageConfig** - Entry page configuration for SSG (passed to Rust).
- `interface` **SsgPageData** - Page data for SSG.
- `function` **resolveSsgOptions** - Resolves SSG options with defaults.
- `function` **renderTemplate** - Simple mustache-like template rendering.
- `function` **extractTitle** - Extracts title from content or frontmatter.
- `function` **_generateNavHtml** - Generates navigation HTML from nav groups.
- `function` **_generateTocHtml** - Generates TOC HTML from toc entries.
- `function` **generateBareHtmlPage** - Generates bare HTML page (no navigation, no styles).
- `function` **generateHtmlPage** - Generates HTML page with navigation using Rust NAPI bindings.
- `function` **getOutputPath** - Converts a markdown file path to its corresponding HTML output path.
- `function` **getUrlPath** - Converts a markdown file path to a relative URL path.
- `function` **getHref** - Converts a markdown file path to an href.
- `function` **getOgImagePath** - Gets the OG image output path for a given markdown file.
- `function` **getOgImageUrl** - Gets the OG image URL for use in meta tags.
If siteUrl is provided, returns an a...
- `function` **getDisplayTitle** - Gets display title from file path.
- `function` **formatTitle** - Formats a file/dir name as a title.
- `function` **collectMarkdownFiles** - Collects all markdown files from the source directory.
- `interface` **NavGroup** - Navigation group for hierarchical navigation.
- `function` **buildNavItems** - Builds navigation items from markdown files, grouped by directory.
- `function` **buildSsg** - Builds all markdown files to static HTML.

### [theme-renderer](./theme-renderer.md)

- `type` **ThemeComponent** - Theme component type.
- `interface` **ThemeProps** - Props passed to the theme component.
- `interface` **PageData** - Page data for rendering.
- `interface` **ThemeRenderOptions** - Theme render options.
- `function` **renderPage** - Renders a page using the theme component.
- `function` **renderAllPages** - Renders all pages and generates type definitions.
- `function` **generateTypes** - Generates TypeScript type definitions from page frontmatter.
- `function` **DefaultTheme** - Default theme component.
A minimal theme that renders page content with basic st...
- `function` **createTheme** - Creates a theme with layout switching support.

### [theme](./theme.md)

- `interface` **ThemeColors** - Theme color configuration.
- `interface` **ThemeLayout** - Theme layout configuration.
- `interface` **ThemeFonts** - Theme font configuration.
- `interface` **ThemeHeader** - Theme header configuration.
- `interface` **ThemeFooter** - Theme footer configuration.
- `interface` **SocialLinks** - Social links configuration.
- `interface` **ThemeEmbed** - Embedded HTML content for specific positions in the page layout.
- `interface` **ThemeConfig** - Complete theme configuration.
- `interface` **ResolvedThemeConfig** - Resolved theme configuration (after merging with defaults).
- `function` **deepMerge** - Deep merge two objects.
- `function` **defineTheme** - Defines a theme configuration with type checking.
- `function` **mergeThemes** - Merges multiple theme configurations.
Later themes override earlier ones.
- `function` **resolveTheme** - Resolves a theme configuration by merging with its extends chain and defaults.
- `function` **themeToNapi** - Converts resolved theme to the format expected by Rust NAPI.
- `interface` **NapiThemeColors** - NAPI-compatible theme colors type.
- `interface` **NapiThemeFonts** - NAPI-compatible theme fonts type.
- `interface` **NapiThemeLayout** - NAPI-compatible theme layout type.
- `interface` **NapiThemeHeader** - NAPI-compatible theme header type.
- `interface` **NapiThemeFooter** - NAPI-compatible theme footer type.
- `interface` **NapiSocialLinks** - NAPI-compatible social links type.
- `interface` **NapiThemeEmbed** - NAPI-compatible theme embed type.
- `interface` **NapiThemeConfig** - NAPI-compatible theme configuration type.

### [transform](./transform.md)

- `interface` **NapiBindings** - NAPI bindings for Rust-based Markdown processing.
Provides access to compiled Ru...
- `interface` **OgImageData** - OG image data for generating social media preview images.
- `interface` **OgImageConfig** - OG image configuration.
- `interface` **JsTransformOptions** - Options for Rust-based Markdown transformation.
Controls which Markdown extensio...
- `function` **loadNapiBindings** - Lazily loads and caches NAPI bindings.
This function uses lazy loading to defer ...
- `interface` **SsgTransformOptions** - SSG-specific transform options.
- `function` **parseFrontmatter** - Parses YAML frontmatter from Markdown content.
Uses proper YAML parser for full ...
- `function` **buildTocTree** - Builds nested TOC tree from flat list.
- `function` **generateModuleCode** - Generates the JavaScript module code.
- `function` **extractImports** - Extracts imports from Markdown content.
Supports importing components for intera...
- `function` **generateOgImageSvg** - Generates an OG image SVG using the Rust-based generator.
This function uses the...

### [types](./types.md)

- `interface` **HeroAction** - Hero section action button.
- `interface` **HeroImage** - Hero section image configuration.
- `interface` **HeroConfig** - Hero section configuration for entry page.
- `interface` **FeatureConfig** - Feature card for entry page.
- `interface` **EntryPageConfig** - Entry page frontmatter configuration.
- `interface` **SsgOptions** - SSG (Static Site Generation) options.
- `interface` **ResolvedSsgOptions** - Resolved SSG options.
- `interface` **OxContentOptions** - Plugin options.
- `interface` **ResolvedOptions** - Resolved options with all defaults applied.
- `interface` **OgImageOptions** - OG image generation options.
Uses Chromium-based rendering with customizable tem...
- `interface` **ResolvedOgImageOptions** - Resolved OG image options with all defaults applied.
- `interface` **MarkdownTransformer** - Custom AST transformer.
- `interface` **TransformContext** - Transform context passed to transformers.
- `interface` **MarkdownNode** - Markdown AST node (simplified for TypeScript).
- `interface` **TransformResult** - Transform result.
- `interface` **TocEntry** - Table of contents entry.
- `interface` **DocsOptions** - Options for source documentation generation.
- `interface` **ResolvedDocsOptions** - Resolved docs options with all defaults applied.
- `interface` **DocEntry** - A single documentation entry extracted from source.
- `interface` **ParamDoc** - Parameter documentation.
- `interface` **ReturnDoc** - Return type documentation.
- `interface` **ExtractedDocs** - Extracted documentation for a single file.
- `interface` **NavItem** - Navigation item for sidebar navigation.
- `interface` **SearchOptions** - Options for full-text search.
- `interface` **ResolvedSearchOptions** - Resolved search options.
- `interface` **SearchDocument** - Search document structure.
- `interface` **SearchResult** - Search result structure.
- `interface` **LocaleConfig** - Locale configuration.
- `interface` **I18nOptions** - i18n (internationalization) options.
- `interface` **ResolvedI18nOptions** - Resolved i18n options with all defaults applied.