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/serve.tsmodified+3-23
Changes to packages/bunpress/src/serve.ts
@@ -29,7 +29,9 @@ import { clearTemplateCache, render } from './template-loader'
2929import { messagePreviewCSS, renderMessagePreview } from './message-previews'
3030import { getThemeCSS } from './themes'
3131import { buildTocHierarchy, defaultTocConfig, extractHeadings, filterHeadings, generateInlineTocHtml, generateSlug, markdownHeadingText, reserveUniqueSlug } from './toc'
32import { siteUrl } from './site-url'
32import { getConfiguredBasePath, siteUrl } from './site-url'
33
34export { getConfiguredBasePath } from './site-url'
3335import { decodeHtmlEntities, escapeHtmlAttribute } from './html-entities'
3436
3537export { decodeHtmlEntities } from './html-entities'
@@ -901,28 +903,6 @@ function generateNavScreen(config: BunPressConfig, currentPath: string = ''): st
901903 </div>`
902904}
903905
904export function getConfiguredBasePath(config: BunPressConfig): string {
905 if (config.basePath) {
906 const normalized = config.basePath.trim().replace(/\/+$/, '')
907 if (!normalized || normalized === '/')
908 return ''
909 return normalized.startsWith('/') ? normalized : `/${normalized}`
910 }
911
912 const baseUrl = siteUrl(config)
913 if (!baseUrl) {
914 return ''
915 }
916
917 try {
918 const pathname = new URL(baseUrl).pathname.replace(/\/+$/, '')
919 return pathname === '/' ? '' : pathname
920 }
921 catch {
922 return ''
923 }
924}
925
926906export function stripConfiguredBasePath(config: BunPressConfig, pathname: string): string {
927907 const basePath = getConfiguredBasePath(config)
928908 if (!basePath)