11import { createResolver } from 'nuxt/kit'
22import { parseMdc } from './helpers/mdc-parser.mjs'
3+ import { CLI_DOCS_PREFIX , CLI_DOCS_REFS , CLI_DOCS_REPO } from './shared/utils/cli-docs'
34
45const { resolve } = createResolver ( import . meta. url )
56
@@ -246,10 +247,10 @@ export default defineNuxtConfig({
246247 '/docs/3.x/api/kit' : { redirect : '/docs/3.x/api/kit/modules' , prerender : false } ,
247248 '/docs/4.x/api/kit' : { redirect : '/docs/4.x/api/kit/modules' , prerender : false } ,
248249 '/docs/5.x/api/kit' : { redirect : '/docs/5.x/api/kit/modules' , prerender : false } ,
249- '/docs/api/commands' : { redirect : '/docs/api/commands/dev ' , prerender : false } ,
250- '/docs/3.x/api/commands' : { redirect : '/docs/3.x/api/commands/dev ' , prerender : false } ,
251- '/docs/4.x/api/commands' : { redirect : '/docs/4.x/api/commands/dev ' , prerender : false } ,
252- '/docs/5.x/api/commands' : { redirect : '/docs/5.x/api/commands/dev ' , prerender : false } ,
250+ '/docs/api/commands' : { redirect : '/docs/api/commands/overview ' , prerender : false } ,
251+ '/docs/3.x/api/commands' : { redirect : '/docs/3.x/api/commands/overview ' , prerender : false } ,
252+ '/docs/4.x/api/commands' : { redirect : '/docs/4.x/api/commands/overview ' , prerender : false } ,
253+ '/docs/5.x/api/commands' : { redirect : '/docs/5.x/api/commands/overview ' , prerender : false } ,
253254 '/docs/api/advanced' : { redirect : '/docs/api/advanced/hooks' , prerender : false } ,
254255 '/docs/3.x/api/advanced' : { redirect : '/docs/3.x/api/advanced/hooks' , prerender : false } ,
255256 '/docs/4.x/api/advanced' : { redirect : '/docs/4.x/api/advanced/hooks' , prerender : false } ,
@@ -537,6 +538,15 @@ export default defineNuxtConfig({
537538 } ,
538539 hooks : {
539540 'content:file:beforeParse' : async ( { file } ) => {
541+ // Command docs are served from `nuxt/cli`, but Content only ships the markdown,
542+ // not the terminal captures committed beside it. Root-relative image sources are
543+ // repo-relative, so resolve them against the ref this page was parsed from: a
544+ // hardcoded ref would serve `main`'s captures on the 3.x tree.
545+ const collection = file . id . split ( '/' ) [ 0 ] as keyof typeof CLI_DOCS_REFS
546+ if ( file . id . includes ( `/${ CLI_DOCS_PREFIX } /` ) && CLI_DOCS_REFS [ collection ] ) {
547+ const base = `https://raw.githubusercontent.com/${ CLI_DOCS_REPO } /${ CLI_DOCS_REFS [ collection ] } `
548+ file . body = file . body . replaceAll ( / ( ! \[ [ ^ \] ] * \] \( ) \/ (? ! \/ ) / g, `$1${ base } /` )
549+ }
540550 if ( file . id . startsWith ( 'docsv5/' ) ) {
541551 file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/5.x/' )
542552 // Pages that only exist on main (5.x) but are linked as /docs/4.x/* from
@@ -556,6 +566,9 @@ export default defineNuxtConfig({
556566 if ( file . id . startsWith ( 'docsv4/' ) ) {
557567 file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/4.x/' )
558568 }
569+ if ( file . id . startsWith ( 'docsv3/' ) ) {
570+ file . body = file . body . replaceAll ( / \( \/ d o c s \/ (? ! \d \. x ) / g, '(/docs/3.x/' )
571+ }
559572 } ,
560573 'content:file:afterParse' : async ( { file, content } ) => {
561574 if ( file . id === 'index/index.yml' ) {
@@ -631,7 +644,11 @@ export default defineNuxtConfig({
631644 } ,
632645 image : {
633646 format : [ 'webp' , 'jpeg' , 'jpg' , 'png' , 'svg' ] ,
634- provider : 'ipx'
647+ provider : 'ipx' ,
648+ // Opt-out escape hatch for images IPX must not touch, used by `DocsProseImg`.
649+ providers : {
650+ none : { provider : 'none' }
651+ }
635652 } ,
636653 llms : {
637654 domain : 'https://nuxt.com' ,
0 commit comments