@@ -14,7 +14,6 @@ const OUTPUT_FILE = path.join(process.cwd(), 'public', 'search-index.json');
1414interface  SearchDocument  { 
1515  id : string ; 
1616  title : string ; 
17-   folderName : string ; 
1817  content : string ; 
1918  url : string ; 
2019  headings : { 
@@ -87,17 +86,17 @@ async function extractTextFromMDX(filePath: string): Promise<SearchDocument> {
8786  // Extract headings with IDs 
8887  const  headings  =  extractHeadings ( content ) ; 
8988
90-   // Derive a URL from the folder structure 
91-   const  relativePath  =  path . relative ( DOCS_ROOT ,  path . dirname ( filePath ) ) ;  // Get folder name 
92-   const  url  =  `/docs/${ relativePath }  ;  // Generate URL based on the folder structure 
93-   const  folderName  =  relativePath . split ( '/' ) . pop ( )  ||  relativePath ;  // Extract last folder name 
89+   // Derive a URL from the file name 
90+   const  pathWithoutExtension  =  path 
91+     . relative ( DOCS_ROOT ,  filePath ) 
92+     . replace ( / \. m d x $ / ,  '' ) ; 
93+   const  url  =  `/docs/${ pathWithoutExtension }  ; 
9494
9595  return  { 
96-     id : relativePath ,  // Use folder name as ID 
97-     title : data . title  ||  relativePath ,  // Use frontmatter title or fallback to folder name 
98-     folderName,  // Add folder name as a searchable field 
99-     content : plainText . toString ( ) . replace ( / \n + / g,  ' ' ) . trim ( ) ,  // Normalize whitespace 
96+     id : pathWithoutExtension ,  // Use file name as ID 
97+     title : data . title  ||  pathWithoutExtension ,  // Use frontmatter title or fallback to path 
10098    url, 
99+     content : plainText . toString ( ) . replace ( / \n + / g,  ' ' ) . trim ( ) , 
101100    headings,  // Include extracted headings with IDs 
102101  } ; 
103102} 
0 commit comments