@movk/nuxt-docs 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/error.vue +2 -2
- package/app/pages/docs/[...slug].vue +15 -0
- package/app/workers/prettier.js +6 -6
- package/modules/config.ts +29 -33
- package/modules/md-rewrite.ts +23 -0
- package/nuxt.config.ts +22 -6
- package/package.json +1 -1
package/app/error.vue
CHANGED
|
@@ -47,11 +47,11 @@ provide('navigation', rootNavigation)
|
|
|
47
47
|
<NuxtLoadingIndicator color="var(--ui-primary)" :height="2" />
|
|
48
48
|
|
|
49
49
|
<div :class="{ root: route.path.startsWith('/docs/') }">
|
|
50
|
-
<Header />
|
|
50
|
+
<Header v-if="$route.meta.header !== false" />
|
|
51
51
|
|
|
52
52
|
<UError :error="error" />
|
|
53
53
|
|
|
54
|
-
<Footer />
|
|
54
|
+
<Footer v-if="$route.meta.footer !== false" />
|
|
55
55
|
|
|
56
56
|
<ClientOnly>
|
|
57
57
|
<LazyUContentSearch :files="files" :navigation="navigation" />
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { ContentNavigationItem } from '@nuxt/content'
|
|
3
3
|
import { kebabCase } from 'scule'
|
|
4
|
+
import { joinURL } from 'ufo'
|
|
4
5
|
|
|
5
6
|
definePageMeta({
|
|
6
7
|
layout: 'docs',
|
|
@@ -80,6 +81,20 @@ const communityLinks = computed(() => {
|
|
|
80
81
|
return filterValidLinks([...links, ...(toc?.bottom?.links || [])])
|
|
81
82
|
})
|
|
82
83
|
|
|
84
|
+
// Pre-render the markdown path + add it to alternate links
|
|
85
|
+
const site = useSiteConfig()
|
|
86
|
+
const path = computed(() => route.path.replace(/\/$/, ''))
|
|
87
|
+
prerenderRoutes([joinURL('/raw', `${path.value}.md`)])
|
|
88
|
+
useHead({
|
|
89
|
+
link: [
|
|
90
|
+
{
|
|
91
|
+
rel: 'alternate',
|
|
92
|
+
href: joinURL(site.url, 'raw', `${path.value}.md`),
|
|
93
|
+
type: 'text/markdown'
|
|
94
|
+
}
|
|
95
|
+
]
|
|
96
|
+
})
|
|
97
|
+
|
|
83
98
|
useSeoMeta({
|
|
84
99
|
title,
|
|
85
100
|
ogTitle: title,
|
package/app/workers/prettier.js
CHANGED
|
@@ -16,12 +16,12 @@ function handleMessage(message) {
|
|
|
16
16
|
async function handleFormatMessage(message) {
|
|
17
17
|
if (!globalThis.prettier) {
|
|
18
18
|
await Promise.all([
|
|
19
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
20
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
21
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
22
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
23
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
24
|
-
import('https://cdn.jsdelivr.net/npm/prettier@3.
|
|
19
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/standalone.js'),
|
|
20
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/plugins/babel.js'),
|
|
21
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/plugins/estree.js'),
|
|
22
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/plugins/html.js'),
|
|
23
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/plugins/markdown.js'),
|
|
24
|
+
import('https://cdn.jsdelivr.net/npm/prettier@3.7.4/plugins/typescript.js')
|
|
25
25
|
])
|
|
26
26
|
}
|
|
27
27
|
|
package/modules/config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createResolver, defineNuxtModule } from '@nuxt/kit'
|
|
2
|
+
import { join } from 'pathe'
|
|
2
3
|
import { defu } from 'defu'
|
|
3
4
|
import { getGitBranch, getGitEnv, getLocalGitInfo } from '../utils/git'
|
|
4
5
|
import { getPackageJsonMetadata, inferSiteURL } from '../utils/meta'
|
|
@@ -57,40 +58,35 @@ export default defineNuxtModule({
|
|
|
57
58
|
until: new Date().toISOString()
|
|
58
59
|
})
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const layerPath = resolve('..')
|
|
62
|
+
const allowedComponents = [
|
|
63
|
+
resolve('../app/components/content/CommitChangelog.vue'),
|
|
64
|
+
resolve('../app/components/content/ComponentEmits.vue'),
|
|
65
|
+
resolve('../app/components/content/ComponentExample.vue'),
|
|
66
|
+
resolve('../app/components/content/ComponentProps.vue'),
|
|
67
|
+
resolve('../app/components/content/ComponentSlots.vue'),
|
|
68
|
+
resolve('../app/components/content/PageLastCommit.vue'),
|
|
69
|
+
resolve('./ai-chat/runtime/components/AiChatToolCall.vue'),
|
|
70
|
+
resolve('./ai-chat/runtime/components/AiChatReasoning.vue'),
|
|
71
|
+
resolve('./ai-chat/runtime/components/AiChatSlideoverFaq.vue'),
|
|
72
|
+
resolve('./ai-chat/runtime/components/AiChatPreStream.vue')
|
|
73
|
+
]
|
|
74
|
+
const userComponentPaths = [
|
|
75
|
+
join(dir, 'app/components'),
|
|
76
|
+
join(dir, 'components'),
|
|
77
|
+
join(dir, 'docs/app/components'),
|
|
78
|
+
join(dir, 'templates/*/app/components')
|
|
79
|
+
]
|
|
61
80
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
'@nuxtjs/plausible',
|
|
72
|
-
'@nuxt/ui',
|
|
73
|
-
(component: { filePath: string }) => {
|
|
74
|
-
const allowedComponents = [
|
|
75
|
-
'CommitChangelog.vue',
|
|
76
|
-
'ComponentEmits.vue',
|
|
77
|
-
'ComponentExample.vue',
|
|
78
|
-
'ComponentProps.vue',
|
|
79
|
-
'ComponentSlots.vue',
|
|
80
|
-
'PageLastCommit.vue',
|
|
81
|
-
'Motion.vue'
|
|
82
|
-
]
|
|
83
|
-
return component.filePath.startsWith(componentsPath)
|
|
84
|
-
&& !allowedComponents.some(name => component.filePath.endsWith(`/content/${name}`))
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
metaFields: {
|
|
88
|
-
type: false,
|
|
89
|
-
props: true,
|
|
90
|
-
slots: 'no-schema' as const,
|
|
91
|
-
events: 'no-schema' as const,
|
|
92
|
-
exposed: false
|
|
93
|
-
}
|
|
81
|
+
// @ts-ignore - component-meta 的类型定义在运行时才能正确解析
|
|
82
|
+
nuxt.hook('component-meta:extend', (options: any) => {
|
|
83
|
+
options.exclude = [
|
|
84
|
+
...(options.exclude || []),
|
|
85
|
+
({ filePath }: { filePath: string }) =>
|
|
86
|
+
filePath.startsWith(layerPath) && !allowedComponents.includes(filePath),
|
|
87
|
+
({ filePath }: { filePath: string }) =>
|
|
88
|
+
userComponentPaths.some(path => filePath.startsWith(path))
|
|
89
|
+
]
|
|
94
90
|
})
|
|
95
91
|
}
|
|
96
92
|
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineNuxtModule } from 'nuxt/kit'
|
|
2
|
+
|
|
3
|
+
export default defineNuxtModule((_options, nuxt) => {
|
|
4
|
+
nuxt.hooks.hook('nitro:init', (nitro) => {
|
|
5
|
+
if (nitro.options.dev || !nitro.options.preset.includes('vercel')) {
|
|
6
|
+
return
|
|
7
|
+
}
|
|
8
|
+
nitro.hooks.hook('compiled', async () => {
|
|
9
|
+
const { resolve } = process.getBuiltinModule('node:path')
|
|
10
|
+
const { readFile, writeFile }
|
|
11
|
+
= process.getBuiltinModule('node:fs/promises')
|
|
12
|
+
const vcJSON = resolve(nitro.options.output.dir, 'config.json')
|
|
13
|
+
const vcConfig = JSON.parse(await readFile(vcJSON, 'utf8'))
|
|
14
|
+
vcConfig.routes.unshift({
|
|
15
|
+
src: '^/docs/(.*)$',
|
|
16
|
+
dest: '/raw/docs/$1.md',
|
|
17
|
+
has: [{ type: 'header', key: 'accept', value: '(.*)text/markdown(.*)' }],
|
|
18
|
+
check: true
|
|
19
|
+
})
|
|
20
|
+
await writeFile(vcJSON, JSON.stringify(vcConfig, null, 2), 'utf8')
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
})
|
package/nuxt.config.ts
CHANGED
|
@@ -7,20 +7,16 @@ const { resolve } = createResolver(import.meta.url)
|
|
|
7
7
|
export default defineNuxtConfig({
|
|
8
8
|
modules: [
|
|
9
9
|
resolve('./modules/config'),
|
|
10
|
-
resolve('./modules/routing'),
|
|
11
|
-
resolve('./modules/css'),
|
|
12
|
-
resolve('./modules/component-example'),
|
|
13
|
-
resolve('./modules/ai-chat'),
|
|
14
10
|
'@nuxt/ui',
|
|
15
11
|
'@nuxt/content',
|
|
16
12
|
'@nuxt/image',
|
|
17
13
|
'@nuxt/a11y',
|
|
18
|
-
'@vueuse/nuxt',
|
|
19
14
|
'@nuxtjs/mcp-toolkit',
|
|
20
15
|
'@nuxtjs/seo',
|
|
16
|
+
'@vueuse/nuxt',
|
|
21
17
|
'nuxt-component-meta',
|
|
22
|
-
'motion-v/nuxt',
|
|
23
18
|
'nuxt-llms',
|
|
19
|
+
'motion-v/nuxt',
|
|
24
20
|
() => {
|
|
25
21
|
extendViteConfig((config) => {
|
|
26
22
|
config.optimizeDeps ||= {}
|
|
@@ -92,6 +88,26 @@ export default defineNuxtConfig({
|
|
|
92
88
|
a11y: {
|
|
93
89
|
logIssues: false
|
|
94
90
|
},
|
|
91
|
+
componentMeta: {
|
|
92
|
+
metaFields: {
|
|
93
|
+
type: false,
|
|
94
|
+
props: true,
|
|
95
|
+
slots: 'no-schema' as const,
|
|
96
|
+
events: 'no-schema' as const,
|
|
97
|
+
exposed: false
|
|
98
|
+
},
|
|
99
|
+
exclude: [
|
|
100
|
+
'@nuxt/ui',
|
|
101
|
+
'@nuxt/content',
|
|
102
|
+
'@nuxt/icon',
|
|
103
|
+
'@nuxt/image',
|
|
104
|
+
'@nuxtjs/color-mode',
|
|
105
|
+
'@nuxtjs/mdc',
|
|
106
|
+
'@nuxtjs/plausible',
|
|
107
|
+
'nuxt/dist',
|
|
108
|
+
'nuxt-og-image'
|
|
109
|
+
]
|
|
110
|
+
},
|
|
95
111
|
fonts: {
|
|
96
112
|
families: [
|
|
97
113
|
{ name: 'Public Sans', provider: 'google', global: true },
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@movk/nuxt-docs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.4",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Modern Nuxt 4 documentation theme with auto-generated component docs, AI chat assistant, MCP server, and complete developer experience optimization.",
|
|
7
7
|
"author": "YiXuan <mhaibaraai@gmail.com>",
|