@@ -2,7 +2,7 @@ import { createResolver } from 'nuxt/kit'
22import { parseMdc } from './helpers/mdc-parser.mjs'
33import { agentHowToCall , agentWhenToUse } from './shared/utils/agents'
44import { CLI_DOCS_PREFIX , CLI_DOCS_REFS , CLI_DOCS_REPO } from './shared/utils/cli-docs'
5- import { CURRENT_DOCS_VERSION , EXCLUDED_DOC_VERSIONS } from './shared/utils/docs'
5+ import { CURRENT_DOCS_VERSION , DOCS_COLLECTION_VERSIONS , EXCLUDED_DOC_VERSIONS , insertDocsVersion } from './shared/utils/docs'
66
77const { resolve } = createResolver ( import . meta. url )
88
@@ -441,7 +441,6 @@ export default defineNuxtConfig({
441441 '/docs/5.x/getting-started/directory-structure' : { redirect : '/docs/4.x/directory-structure' , prerender : false } ,
442442 '/docs/4.x/guide/going-further/modules' : { redirect : '/docs/4.x/guide/modules' , prerender : false } ,
443443 '/docs/5.x/guide/going-further/modules' : { redirect : '/docs/4.x/guide/modules' , prerender : false } ,
444- '/docs/4.x/guide/modules/module-dependencies' : { redirect : '/docs/5.x/guide/modules/module-dependencies' , prerender : false } ,
445444 '/docs/4.x/guide/concepts/rendering-modes' : { redirect : '/docs/4.x/guide/concepts/rendering' , prerender : false } ,
446445 '/docs/5.x/guide/concepts/rendering-modes' : { redirect : '/docs/4.x/guide/concepts/rendering' , prerender : false } ,
447446 '/docs/4.x/guide/directory-structure/nuxt.config' : { redirect : '/docs/4.x/directory-structure/nuxt-config' , prerender : false } ,
@@ -539,27 +538,9 @@ export default defineNuxtConfig({
539538 const base = `https://raw.githubusercontent.com/${ CLI_DOCS_REPO } /${ CLI_DOCS_REFS [ collection ] } `
540539 file . body = file . body . replaceAll ( / ( ! \[ [ ^ \] ] * \] \( ) \/ (? ! \/ ) / g, `$1${ base } /` )
541540 }
542- if ( file . id . startsWith ( 'docsv5/' ) ) {
543- file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/5.x/' )
544- // Pages that only exist on main (5.x) but are linked as /docs/4.x/* from
545- // the 5.x docs. Left unrewritten they 404, which fails the prerender now
546- // that the crawler is on. Only paths whose 5.x counterpart exists belong
547- // here — a blanket 4.x→5.x rewrite would break the ~13 links that point
548- // at pages 5.x dropped (guide/concepts/esm, going-further/internals, …).
549- for ( const path of [
550- 'guide/modules/module-dependencies' ,
551- 'guide/best-practices/accessibility' ,
552- 'guide/concepts/server-components' ,
553- 'guide/recipes/mostly-static-sites'
554- ] ) {
555- file . body = file . body . replaceAll ( `/docs/4.x/${ path } ` , `/docs/5.x/${ path } ` )
556- }
557- }
558- if ( file . id . startsWith ( 'docsv4/' ) ) {
559- file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/4.x/' )
560- }
561- if ( file . id . startsWith ( 'docsv3/' ) ) {
562- file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/3.x/' )
541+ const docsVersion = DOCS_COLLECTION_VERSIONS [ collection ]
542+ if ( docsVersion ) {
543+ file . body = insertDocsVersion ( file . body , docsVersion )
563544 }
564545 } ,
565546 'content:file:afterParse' : async ( { file, content } ) => {
0 commit comments