@@ -76,6 +76,7 @@ function codeTranslationLocalesToTry(locale: string): string[] {
7676type MyOptions = {
7777 indexDocs : boolean ;
7878 indexDocSidebarParentCategories : number ;
79+ includeParentCategoriesInPageTitle : boolean ;
7980 indexBlog : boolean ;
8081 indexPages : boolean ;
8182 language : string | string [ ] ;
@@ -124,6 +125,8 @@ const optionsSchema = Joi.object({
124125 . max ( Number . MAX_SAFE_INTEGER )
125126 . default ( 0 ) ,
126127
128+ includeParentCategoriesInPageTitle : Joi . boolean ( ) . default ( false ) ,
129+
127130 indexBlog : Joi . boolean ( ) . default ( true ) ,
128131
129132 indexPages : Joi . boolean ( ) . default ( false ) ,
@@ -154,6 +157,7 @@ export default function cmfcmfDocusaurusSearchLocal(
154157) : Plugin < unknown > {
155158 let {
156159 indexDocSidebarParentCategories,
160+ includeParentCategoriesInPageTitle,
157161 indexBlog,
158162 indexDocs,
159163 indexPages,
@@ -543,7 +547,7 @@ export const tokenize = (input) => lunr.tokenizer(input)
543547 indexDocSidebarParentCategories > 0 &&
544548 docSidebarParentCategories
545549 ) {
546- sidebarParentCategories = docSidebarParentCategories
550+ sidebarParentCategories = [ ... docSidebarParentCategories ]
547551 . reverse ( )
548552 . slice ( 0 , indexDocSidebarParentCategories )
549553 . join ( " " ) ;
@@ -570,13 +574,29 @@ export const tokenize = (input) => lunr.tokenizer(input)
570574 sectionTitle,
571575 sectionRoute,
572576 type,
573- } ) : MyDocument => ( {
574- id,
575- pageTitle,
576- sectionTitle,
577- sectionRoute,
578- type,
579- } )
577+ docSidebarParentCategories,
578+ } ) : MyDocument => {
579+ let fullTitle = pageTitle ;
580+
581+ if (
582+ includeParentCategoriesInPageTitle &&
583+ docSidebarParentCategories &&
584+ docSidebarParentCategories . length > 0
585+ ) {
586+ fullTitle = [
587+ ...docSidebarParentCategories ,
588+ pageTitle ,
589+ ] . join ( " > " ) ;
590+ }
591+
592+ return {
593+ id,
594+ pageTitle : fullTitle ,
595+ sectionTitle,
596+ sectionRoute,
597+ type,
598+ } ;
599+ }
580600 ) ,
581601 index,
582602 } ) ,
0 commit comments