Skip to content

API

@ogygia/content/vite

The content plugin, plus the preprocess() and extensions() helpers for the svelte config.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

import { … } from '@ogygia/content/vite';

Exports content · extensions · invalidateModuleTree · preprocess · ContentOptions · ContentPreset · ContentHmrOptions

content

function

function content(options?: ContentOptions): [OgygiaPlugin, ...Plugin[]];

extensions

function

The svelte config's full extensions list: .svelte, plus markdown's when content({ markdown }) is set. Pass it straight through: extensions: extensions().

function extensions(): string[];

invalidateModuleTree

function

Invalidate a module and every importer. Returns how many modules were touched.

function invalidateModuleTree(server: ViteDevServer, entry: ModuleNode | undefined): number;

preprocess

function

The svelte config's markdown preprocessor. Spread into preprocess: preprocess: [vitePreprocess(), ...preprocess()]. The markdown preprocessor when content({ markdown }) is set, otherwise nothing. mdsvex loads lazily on first use.

function preprocess(): PreprocessorGroup[];

ContentOptions

interface

interface ContentOptions extends ContentHmrOptions {/*…*/}

ContentOptions.markdown

The markdown pipeline (mdsvex + Shiki: themes, remark plugins, heading ids…): the defaults for every markdown file. Setting it turns markdown on (extensions() adds its extensions).

markdown?: MarkdownOptions;

ContentOptions.presets

Named variants a loader macro opts a whole collection into ({ preset: 'name' }). Requires markdown (the defaults every preset merges over; an empty markdown: {} is fine).

presets?: Record<string, ContentPreset>;

ContentPreset

interface

A named content preset — a partial content config referenced by a literal preset: 'name' on a loader macro (import.meta.og.loader.folder('../docs', { preset: 'name' })). The referencing collection's files compile as their own module VARIANTS (?og_preset=name), so the same file used by another collection under another preset renders independently — never a conflict.

interface ContentPreset {/*…*/}

ContentPreset.markdown

Markdown options merged over markdown (per setting key — depth-2 replace).

markdown?: MarkdownOptions;

ContentHmrOptions

type

type ContentHmrOptions = {
  watchDirs?: string[];
  hmrDebounceMs?: number;
};