ReviewOS

also looking at this

stacks/bunpress

fix: preserve deployment paths in local search results

#91
Merged chris wants to merge codex/search-base-path into main
5 files +81 -23
packages/bunpress/src/search-index.tsmodified+8-0
Changes to packages/bunpress/src/search-index.ts
@@ -2,6 +2,7 @@ import type { BunPressConfig, LocalSearchOptions, SearchConfig } from './types'
22import { Glob, YAML } from 'bun'
33import { join } from 'node:path'
44import { localizeUrl, resolveI18nConfig } from './i18n'
5import { getConfiguredBasePath } from './site-url'
56import { createFenceTracker, stripFencedCode } from './markdown-fences'
67import { unwrapMessageFences } from './message-previews'
78import { generateSlug, markdownHeadingText, reserveUniqueSlug } from './toc'
@@ -473,5 +474,12 @@ export async function buildSearchIndex(docsDir: string, config?: BunPressConfig)
473474 }
474475 }
475476
477 // Apply the deployment prefix after locale fallback has compared page keys.
478 // Every record is still docs-relative here, including a real `docs/` directory.
479 const basePath = config ? getConfiguredBasePath(config) : ''
480 if (basePath) {
481 for (const record of records) record.url = `${basePath}${record.url}`
482 }
483
476484 return applyStoreFields(records, options)
477485}