feat: semantic search (1/n)

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2025-10-05 19:50:52 -04:00
parent f14260b2ba
commit f533902c75
23 changed files with 2955 additions and 502 deletions

View File

@@ -25,6 +25,7 @@ const headerRegex = new RegExp(/h[1-6]/)
export function pageResources(
baseDir: FullSlug | RelativeURL,
staticResources: StaticResources,
cfg?: GlobalConfiguration,
): StaticResources {
const contentIndexPath = joinSegments(baseDir, "static/contentIndex.json")
const contentIndexScript = `const fetchData = fetch("${contentIndexPath}").then(data => data.json())`
@@ -48,6 +49,12 @@ export function pageResources(
spaPreserve: true,
script: contentIndexScript,
},
{
loadTime: "beforeDOMReady",
contentType: "inline",
spaPreserve: true,
script: `const semanticCfg = ${JSON.stringify(cfg?.semanticSearch ?? {})};`,
},
...staticResources.js,
],
additionalHead: staticResources.additionalHead,