dev-server.ts
13 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference
fncreateDevServerCache(): DevServerCacheCreate a dev server cache instance.
Create a dev server cache instance.
Signature
export function createDevServerCache(): DevServerCache
Returns
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
Parameters
-
optionsResolvedOptions -
rootstring -
cacheDevServerCache
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.
interfaceDevServerCacheDev server state for caching.
Dev server state for caching.
Signature
interface DevServerCache
Members
Properties
| Name | Type | Description |
|---|---|---|
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
Parameters
-
htmlstring
Returns
string
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
Parameters
-
cacheDevServerCache -
filePathstring
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>
Parameters
-
filePathstring -
optionsResolvedOptions -
navGroupsNavGroup[] -
siteNamestring -
basestring -
rootstring
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>
Parameters
-
urlstring -
srcDirstring -
extensionsreadonly 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>
Parameters
-
optionsResolvedOptions -
rootstring
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
Parameters
-
urlstring
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",
])
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/", "/__"]