dev-server.ts

Source

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

13 symbols 9 functions 1 interfaces 2 variables 1 modules 19 parameters 3 members 9 returns

Reference

fncreateDevServerCache(): DevServerCacheCreate a dev server cache instance.

Create a dev server cache instance.

Signature

export function createDevServerCache(): DevServerCache

View source

Returns

DevServerCache
fncreateDevServerMiddleware(options: ResolvedOptions, root: string, cache: DevServerCache): Connect.NextHandleFunctionCreate the dev server middleware for SSG page serving.

Create the dev server middleware for SSG page serving.

Signature

export function createDevServerMiddleware(options: ResolvedOptions, root: string, cache: DevServerCache): Connect.NextHandleFunction

View source

Parameters

Returns

Connect.NextHandleFunction
moduledev-serverDev server middleware for ox-content SSG. Serves fully-rendered HTML pages (with navigation, theme, etc.) during vite d…

Dev server middleware for ox-content SSG.

Serves fully-rendered HTML pages (with navigation, theme, etc.) during vite dev, matching the SSG build output.

View source

interfaceDevServerCacheDev server state for caching.

Dev server state for caching.

Signature

interface DevServerCache

View source

Members

Properties
NameTypeDescription
navGroups NavGroup[] | null
Cached navigation groups. Invalidated on file add/unlink.
pages Map<string, string>
Cached rendered HTML keyed by absolute file path.
siteName string | null
Cached site name. Computed once.
fninjectViteHmrClient(html: string): stringInject Vite HMR client script into the HTML.

Inject Vite HMR client script into the HTML.

Signature

function injectViteHmrClient(html: string): string

View source

Parameters

  • html string

Returns

string
fninvalidateNavCache(cache: DevServerCache): voidInvalidate navigation cache (called on file add/unlink).

Invalidate navigation cache (called on file add/unlink).

Signature

export function invalidateNavCache(cache: DevServerCache): void

View source

Parameters

Returns

void
fninvalidatePageCache(cache: DevServerCache, filePath: string): voidInvalidate page cache for a specific file (called on file change).

Invalidate page cache for a specific file (called on file change).

Signature

export function invalidatePageCache(cache: DevServerCache, filePath: string): void

View source

Parameters

Returns

void
fnrenderPage(filePath: string, options: ResolvedOptions, navGroups: NavGroup[], siteName: string, base: string, root: string): Promise<string>Render a single markdown page to full HTML.

Render a single markdown page to full HTML.

Signature

async function renderPage(filePath: string, options: ResolvedOptions, navGroups: NavGroup[], siteName: string, base: string, root: string): Promise<string>

View source

Parameters

Returns

Promise<string>
fnresolveMarkdownFile(url: string, srcDir: string, extensions: readonly string[]): Promise<string | null>Resolve a request URL to a markdown file path. Returns null if no matching file…

Resolve a request URL to a markdown file path. Returns null if no matching file exists.

Signature

async function resolveMarkdownFile(url: string, srcDir: string, extensions: readonly string[]): Promise<string | null>

View source

Parameters

  • url string
  • srcDir string
  • extensions readonly string[]

Returns

Promise<string | null>
fnresolveSiteName(options: ResolvedOptions, root: string): Promise<string>Resolve site name from options or package.json.

Resolve site name from options or package.json.

Signature

async function resolveSiteName(options: ResolvedOptions, root: string): Promise<string>

View source

Parameters

Returns

Promise<string>
fnshouldSkip(url: string): booleanCheck if a request URL should be skipped by the dev server middleware.

Check if a request URL should be skipped by the dev server middleware.

Signature

function shouldSkip(url: string): boolean

View source

Parameters

  • url string

Returns

boolean
variableconst SKIP_EXTENSIONS = new Set([ ".js", ".ts", ".css", ".scss", ".less", ".svg", ".png", ".jpg", ".jpeg", ".gif", ".webp", ".ico", ".woff", ".woff2", ".ttf", ".eot", ".json", ".map", ".mp4", ".webm", ".mp3", ".pdf", ])File extensions to skip in the middleware.

File extensions to skip in the middleware.

Signature

const SKIP_EXTENSIONS = new Set([
  ".js",
  ".ts",
  ".css",
  ".scss",
  ".less",
  ".svg",
  ".png",
  ".jpg",
  ".jpeg",
  ".gif",
  ".webp",
  ".ico",
  ".woff",
  ".woff2",
  ".ttf",
  ".eot",
  ".json",
  ".map",
  ".mp4",
  ".webm",
  ".mp3",
  ".pdf",
])

View source

variableconst VITE_INTERNAL_PREFIXES = ["/@vite/", "/@fs/", "/@id/", "/__"]Vite internal URL prefixes to skip.

Vite internal URL prefixes to skip.

Signature

const VITE_INTERNAL_PREFIXES = ["/@vite/", "/@fs/", "/@id/", "/__"]

View source