Ox Content

theme-renderer.ts

Source

ThemeComponent

type

Theme component type.

Source


ThemeProps

interface

Props passed to the theme component.

Source


PageData

interface

Page data for rendering.

Source


ThemeRenderOptions

interface

Theme render options.

Source


renderPage

function

Renders a page using the theme component.

Source

export function renderPage(
  page: PageData,
  options: ThemeRenderOptions
  ): string

Parameters

Name Type Description
page PageData Page data to render
options ThemeRenderOptions Theme render options

Returns

string - Rendered HTML string


renderAllPages

function

Renders all pages and generates type definitions.

Source

export async function renderAllPages(
  pages: PageData[],
  options: ThemeRenderOptions
  ): Promise<Map<string, string>>

Parameters

Name Type Description
pages PageData[] All pages to render
options ThemeRenderOptions Theme render options

Returns

Promise<Map<string, string>> - Map of output paths to rendered HTML


generateTypes

function

Generates TypeScript type definitions from page frontmatter.

Source

export async function generateTypes(
  pages: PageData[],
  outDir: string
  ): Promise<void>

Parameters

Name Type Description
pages PageData[] All pages
outDir string Output directory for types

Returns

Promise<void> -


DefaultTheme

function

Default theme component. A minimal theme that renders page content with basic styling.

Source

Returns

JSXNode -


createTheme

function

Creates a theme with layout switching support.

Source

Returns

ThemeComponent -

Examples

import { createTheme } from '@ox-content/vite-plugin';
import { DefaultLayout } from './layouts/Default';
import { EntryLayout } from './layouts/Entry';
export default createTheme({
  layouts: {
    default: DefaultLayout,
    entry: EntryLayout,
  },
});