@@ -26,6 +26,18 @@ function filterLocales(allAvailableLocales) {
2626 return allAvailableLocales . filter ( l => requested . has ( l ) ) ;
2727}
2828
29+ // Output basename overrides — force the generated .md filename for specific
30+ // articles regardless of the source filename's casing.
31+ //
32+ // `migration-guide-to-server-side-API-v2.mdx` keeps the uppercase `API` on
33+ // disk, but its page URL (driven by the sidebar id, which Astro lowercases via
34+ // github-slugger) is the all-lowercase form. Without this override the .md
35+ // lands at `/docs/...API-v2.md` and 404s from the lowercase page. Applies to
36+ // English and every locale.
37+ const MD_BASENAME_OVERRIDES = new Map ( [
38+ [ 'migration-guide-to-server-side-API-v2' , 'migration-guide-to-server-side-api-v2' ] ,
39+ ] ) ;
40+
2941// Helper to convert kebab-case file name to PascalCase component name
3042const toPascalCase = ( str ) => {
3143 if ( / ^ \d / . test ( str ) ) return `Error${ str } ` ;
@@ -163,6 +175,7 @@ async function processFiles(dir, reusableComponents, englishFiles) {
163175
164176 // Determine output filename (flattened basename logic)
165177 let basename = entry . name . replace ( / \. ( m d | m d x ) $ / , '' ) ;
178+ basename = MD_BASENAME_OVERRIDES . get ( basename ) ?? basename ;
166179
167180 const destPath = path . join ( OUTPUT_DIR , `${ basename } .md` ) ;
168181
@@ -202,7 +215,8 @@ async function processLocaleFiles(locale, baseComponents, englishFiles) {
202215 let content = cleanFrontmatter ( rawContent ) ;
203216 content = stripContent ( content , components ) ;
204217
205- const basename = entry . name . replace ( / \. ( m d | m d x ) $ / , '' ) ;
218+ const rawBasename = entry . name . replace ( / \. ( m d | m d x ) $ / , '' ) ;
219+ const basename = MD_BASENAME_OVERRIDES . get ( rawBasename ) ?? rawBasename ;
206220 translatedBasenames . add ( basename ) ;
207221 await fs . writeFile ( path . join ( localeOutputDir , `${ basename } .md` ) , content , 'utf-8' ) ;
208222 }
0 commit comments