11import { createMixedbreadSearchAPI } from "fumadocs-core/search/mixedbread" ;
22import Mixedbread from "@mixedbread/sdk" ;
33import { SortedResult } from "fumadocs-core/search" ;
4+ import { formatSlugDisplayName } from "@/lib/breadcrumb-utils" ;
45
56export const dynamic = "force-dynamic" ;
67
@@ -13,13 +14,9 @@ function getBreadcrumbsFromUrl(url: string): string[] {
1314 const normalized = segments [ 0 ] === "v6" ? segments . slice ( 1 ) : segments ;
1415 if ( normalized . length === 0 ) return [ ] ;
1516 // Ancestors only (exclude last = current page), or full path for section roots
16- const breadcrumbSegments = normalized . length > 1 ? normalized . slice ( 0 , - 1 ) : normalized ;
17- return breadcrumbSegments . map ( ( s ) =>
18- s
19- . split ( / [ - _ ] / )
20- . map ( ( w ) => w . charAt ( 0 ) . toUpperCase ( ) + w . slice ( 1 ) . toLowerCase ( ) )
21- . join ( " " ) ,
22- ) ;
17+ const breadcrumbSegments =
18+ normalized . length > 1 ? normalized . slice ( 0 , - 1 ) : normalized ;
19+ return breadcrumbSegments . map ( ( s ) => formatSlugDisplayName ( s ) ) ;
2320}
2421
2522function slugger ( value : string ) : string {
@@ -35,7 +32,10 @@ function removeMd(md: string): string {
3532 if ( typeof md !== "string" ) return "" ;
3633 try {
3734 return md
38- . replace ( / ^ { 0 , 3 } ( (?: - [ \t ] * ) { 3 , } | (?: _ [ \t ] * ) { 3 , } | (?: \* [ \t ] * ) { 3 , } ) (?: \n + | $ ) / gm, "" )
35+ . replace (
36+ / ^ { 0 , 3 } ( (?: - [ \t ] * ) { 3 , } | (?: _ [ \t ] * ) { 3 , } | (?: \* [ \t ] * ) { 3 , } ) (?: \n + | $ ) / gm,
37+ "" ,
38+ )
3939 . replace ( / ^ ( [ \s \t ] * ) ( [ * \- + ] | \d + \. ) \s + / gm, "$1" )
4040 . replace ( / \n = { 2 , } / g, "\n" )
4141 . replace ( / ^ [ = - ] { 2 , } \s * $ / gm, "" )
@@ -49,7 +49,10 @@ function removeMd(md: string): string {
4949 . replace ( / ! \[ ( .* ?) \] [ [ ( ] .* ?[ \] ) ] / g, "" )
5050 . replace ( / \[ ( [ \s \S ] * ?) \] \s * [ ( [ ] .* ?[ ) \] ] / g, "$1" )
5151 . replace ( / ^ ( \n ) ? \s { 0 , 3 } > \s ? / gm, "$1" )
52- . replace ( / ^ ( \n ) ? \s { 0 , } # { 1 , 6 } \s * ( ( .+ ) ) ? + # + $ | ^ ( \n ) ? \s { 0 , } # { 1 , 6 } \s * ( ( .+ ) ) ? $ / gm, "$1$3$4$6" )
52+ . replace (
53+ / ^ ( \n ) ? \s { 0 , } # { 1 , 6 } \s * ( ( .+ ) ) ? + # + $ | ^ ( \n ) ? \s { 0 , } # { 1 , 6 } \s * ( ( .+ ) ) ? $ / gm,
54+ "$1$3$4$6" ,
55+ )
5356 . replace ( / ( [ * ] + ) ( \S ) ( .* ?\S ) ? ?\1/ g, "$2$3" )
5457 . replace ( / ( ^ | \W ) ( [ _ ] + ) ( \S ) ( .* ?\S ) ? ?\2( $ | \W ) / g, "$1$3$4$5" )
5558 . replace ( / ( ` { 3 , } ) ( .* ?) \1/ gm, "$2" )
@@ -88,7 +91,8 @@ export const { GET } = createMixedbreadSearchAPI({
8891 breadcrumbs,
8992 } ,
9093 ] ;
91- const heading = item . type === "text" ? extractHeadingTitle ( item . text ) : "" ;
94+ const heading =
95+ item . type === "text" ? extractHeadingTitle ( item . text ) : "" ;
9296 if ( heading )
9397 chunkResults . push ( {
9498 id : `${ base } -heading` ,
0 commit comments