File tree Expand file tree Collapse file tree
vuepress/docs/.vuepress/theme Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,18 @@ export const generateSidebar = (): SidebarConfig => {
1818 cwd : docsDirectory ,
1919 mark : true ,
2020 } )
21- . filter ( ( d : string ) => statSync ( path . join ( docsDirectory , d ) ) . isDirectory ( ) ) ;
21+ . filter ( ( d : string ) => statSync ( path . join ( docsDirectory , d ) ) . isDirectory ( ) )
22+ . sort ( ( a , b ) => {
23+ const aStartsWithB = a . toLowerCase ( ) . startsWith ( "b" ) ;
24+ const bStartsWithB = b . toLowerCase ( ) . startsWith ( "b" ) ;
25+
26+ // If only one starts with 'b', put it last
27+ if ( aStartsWithB && ! bStartsWithB ) return 1 ;
28+ if ( ! aStartsWithB && bStartsWithB ) return - 1 ;
29+
30+ // If both start with 'b' or neither starts with 'b', sort alphabetically
31+ return a . localeCompare ( b ) ;
32+ } ) ;
2233
2334 // get all md files in the root of docs
2435 const rootMdFiles = glob
@@ -80,7 +91,6 @@ export const generateSidebar = (): SidebarConfig => {
8091 collapsible : true ,
8192 link : indexFile ? `/${ repoPath } /${ indexFile } ` : undefined ,
8293 children : sortByOrderProperty ( children ) ,
83- order : sectionFrontmatter [ "sectionOrder" ] ?? 1 ,
8494 } ;
8595 } ) ;
8696
Original file line number Diff line number Diff line change @@ -166,11 +166,27 @@ export default hopeTheme({
166166 } ,
167167 } ,
168168
169+ maxSuggestions : 10 ,
170+
171+ isSearchable : ( page ) => page . path !== "/" ,
172+
169173 getExtraFields : ( page ) => {
170174 const extraFields = [ ] ;
171175
172176 if ( page . content ) {
173- extraFields . push ( page . content ) ;
177+ const cleanContent = page . content
178+ . replace ( / # { 1 , 6 } \s + / g, "" ) // Remove headers
179+ . replace ( / \* \* ( [ ^ * ] + ) \* \* / g, "$1" ) // Remove bold
180+ . replace ( / \* ( [ ^ * ] + ) \* / g, "$1" ) // Remove italic
181+ . replace ( / ` ( [ ^ ` ] + ) ` / g, "$1" ) // Remove inline code
182+ . replace ( / ` ` ` [ \s \S ] * ?` ` ` / g, "" ) // Remove code blocks
183+ . replace ( / \[ ( [ ^ \] ] + ) \] \( [ ^ ) ] + \) / g, "$1" ) // Remove links, keep text
184+ . split ( "\n" )
185+ . filter ( ( line ) => line . trim ( ) . length > 10 ) // Only meaningful lines
186+ . slice ( 0 , 10 ) // Limit to first 10 paragraphs
187+ . join ( " " ) ;
188+
189+ extraFields . push ( cleanContent ) ;
174190 }
175191
176192 return extraFields ;
You can’t perform that action at this time.
0 commit comments