@@ -81,5 +81,55 @@ export async function generateMetadata(props: {
81
81
const path = `/${ params . slug ?. join ( "/" ) || "" } ` ;
82
82
const routeMetadata = getRouteMetadata ( path ) ;
83
83
84
- return createMetadata ( routeMetadata ) ;
84
+ const pathParts = path . split ( "/" ) . filter ( Boolean ) ;
85
+
86
+ const genericTitles = [
87
+ "Overview" ,
88
+ "Installation" ,
89
+ "Quickstart" ,
90
+ "Concepts" ,
91
+ "Getting Started" ,
92
+ ] ;
93
+
94
+ let title = page . data . title ;
95
+
96
+ if ( page . file . name === "index" || genericTitles . includes ( title ) ) {
97
+ let sectionName =
98
+ page . file . name === "index"
99
+ ? pathParts [ pathParts . length - 1 ]
100
+ : pathParts [ pathParts . length - 2 ] || pathParts [ pathParts . length - 1 ] ;
101
+
102
+ if ( sectionName === "api" && pathParts . length >= 2 ) {
103
+ const parentSection = pathParts [ pathParts . length - 2 ] ;
104
+ if ( parentSection === "runes" || parentSection === "ordinals" ) {
105
+ const capitalizedParent =
106
+ parentSection . charAt ( 0 ) . toUpperCase ( ) + parentSection . slice ( 1 ) ;
107
+ sectionName = `${ capitalizedParent } API` ;
108
+ }
109
+ }
110
+
111
+ const sectionTitle = sectionName
112
+ . split ( "-" )
113
+ . map ( ( word ) => word . charAt ( 0 ) . toUpperCase ( ) + word . slice ( 1 ) )
114
+ . join ( " " )
115
+ . replace ( "Api" , "API" )
116
+ . replace ( "Js" , "JS" )
117
+ . replace ( "Sdk" , "SDK" ) ;
118
+
119
+ if ( page . file . name === "index" ) {
120
+ title = `${ sectionTitle } Overview` ;
121
+ } else {
122
+ title = `${ sectionTitle } ${ title } ` ;
123
+ }
124
+ }
125
+
126
+ const pageMetadata : Partial < Metadata > = {
127
+ title,
128
+ description : page . data . description ,
129
+ } ;
130
+
131
+ return createMetadata ( {
132
+ ...routeMetadata ,
133
+ ...pageMetadata ,
134
+ } ) ;
85
135
}
0 commit comments