undocs 0.2.13 → 0.2.15
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/.unjs/app.config.ts +0 -4
- package/app/components/AppHeader.vue +20 -21
- package/app/components/global/ProseCodeIcon.vue +83 -0
- package/app/components/global/ReadMore.vue +2 -2
- package/app/layouts/docs.vue +4 -5
- package/app/modules/theme.ts +49 -0
- package/app/nuxt.config.ts +1 -4
- package/app/pages/[...slug].vue +11 -2
- package/app/pages/index.vue +1 -1
- package/app/utils/nav.ts +36 -0
- package/app/utils/title.ts +9 -0
- package/cli/setup.mjs +0 -10
- package/package.json +1 -2
- package/app/modules/tailwind.ts +0 -18
- package/app/utils/label.ts +0 -9
- /package/schema/{config.ts → config.schema.ts} +0 -0
package/app/.unjs/app.config.ts
CHANGED
|
@@ -7,20 +7,15 @@ const appConfig = useAppConfig()
|
|
|
7
7
|
|
|
8
8
|
const { metaSymbol } = useShortcuts()
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
label: toLabel(nav._path.substring(1)),
|
|
20
|
-
to: nav._path,
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
.filter(Boolean)
|
|
10
|
+
const docsNav = useDocsNav()
|
|
11
|
+
|
|
12
|
+
const headerLinks = computed(() => {
|
|
13
|
+
return docsNav.links.map((link) => {
|
|
14
|
+
return {
|
|
15
|
+
...link,
|
|
16
|
+
children: link.children?.filter((child) => !child.children || child.children.some((c) => c.to === child.to)),
|
|
17
|
+
}
|
|
18
|
+
})
|
|
24
19
|
})
|
|
25
20
|
</script>
|
|
26
21
|
|
|
@@ -33,26 +28,30 @@ const navLinks = computed(() => {
|
|
|
33
28
|
{{ appConfig.site.name }}
|
|
34
29
|
</span>
|
|
35
30
|
</NuxtLink>
|
|
36
|
-
</template>
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
<div class="ml-8 lg:flex hidden">
|
|
33
|
+
<UContentSearchButton label="Search..." />
|
|
34
|
+
</div>
|
|
40
35
|
</template>
|
|
41
36
|
|
|
37
|
+
<!-- <template #center>
|
|
38
|
+
<UContentSearchButton label="Search..." class="lg:flex hidden" />
|
|
39
|
+
</template> -->
|
|
40
|
+
|
|
42
41
|
<template #right>
|
|
43
|
-
<UHeaderLinks :links="
|
|
42
|
+
<UHeaderLinks :links="headerLinks" class="hidden md:flex mr-4" v-if="docsNav.links.length > 1" />
|
|
44
43
|
|
|
45
44
|
<UTooltip class="lg:hidden" text="Search" :shortcuts="[metaSymbol, 'K']">
|
|
46
45
|
<UContentSearchButton :label="null" />
|
|
47
46
|
</UTooltip>
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
<ColorPicker />
|
|
50
49
|
|
|
51
|
-
<SocialButtons
|
|
50
|
+
<SocialButtons />
|
|
52
51
|
</template>
|
|
53
52
|
|
|
54
53
|
<template #panel>
|
|
55
|
-
<UNavigationTree :links="
|
|
54
|
+
<UNavigationTree :links="docsNav.links" default-open :multiple="false" />
|
|
56
55
|
</template>
|
|
57
56
|
</UHeader>
|
|
58
57
|
</template>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps({
|
|
3
|
+
icon: {
|
|
4
|
+
type: String,
|
|
5
|
+
default: undefined,
|
|
6
|
+
},
|
|
7
|
+
filename: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: undefined,
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const config = {
|
|
14
|
+
'.config': 'vscode-icons:file-type-config',
|
|
15
|
+
// '.plugin': 'vscode-icons:file-type-plugin',
|
|
16
|
+
'package.json': 'vscode-icons:file-type-node',
|
|
17
|
+
'tsconfig.json': 'vscode-icons:file-type-tsconfig',
|
|
18
|
+
'.npmrc': 'vscode-icons:file-type-npm',
|
|
19
|
+
'.editorconfig': 'vscode-icons:file-type-editorconfig',
|
|
20
|
+
'.eslintrc': 'vscode-icons:file-type-eslint',
|
|
21
|
+
'.eslintrc.cjs': 'vscode-icons:file-type-eslint',
|
|
22
|
+
'.eslintignore': 'vscode-icons:file-type-eslint',
|
|
23
|
+
'.gitignore': 'vscode-icons:file-type-git',
|
|
24
|
+
'yarn.lock': 'vscode-icons:file-type-yarn',
|
|
25
|
+
'.env': 'vscode-icons:file-type-dotenv',
|
|
26
|
+
'.env.example': 'vscode-icons:file-type-dotenv',
|
|
27
|
+
'.vscode/settings.json': 'vscode-icons:file-type-vscode',
|
|
28
|
+
'.nuxtrc': 'vscode-icons:file-type-nuxt',
|
|
29
|
+
'.nuxtignore': 'vscode-icons:file-type-nuxt',
|
|
30
|
+
'nuxt.config.ts': 'vscode-icons:file-type-nuxt',
|
|
31
|
+
'nuxt.schema.ts': 'vscode-icons:file-type-nuxt',
|
|
32
|
+
'tailwind.config.js': 'vscode-icons:file-type-tailwind',
|
|
33
|
+
'tailwind.config.ts': 'vscode-icons:file-type-tailwind',
|
|
34
|
+
ts: 'vscode-icons:file-type-typescript',
|
|
35
|
+
tsx: 'vscode-icons:file-type-typescript',
|
|
36
|
+
mjs: 'vscode-icons:file-type-js',
|
|
37
|
+
cjs: 'vscode-icons:file-type-js',
|
|
38
|
+
js: 'vscode-icons:file-type-js',
|
|
39
|
+
jsx: 'vscode-icons:file-type-js',
|
|
40
|
+
md: 'vscode-icons:file-type-markdown',
|
|
41
|
+
py: 'vscode-icons:file-type-python',
|
|
42
|
+
ico: 'vscode-icons:file-type-favicon',
|
|
43
|
+
npm: 'vscode-icons:file-type-npm',
|
|
44
|
+
pnpm: 'vscode-icons:file-type-pnpm',
|
|
45
|
+
npx: 'vscode-icons:file-type-npm',
|
|
46
|
+
yarn: 'vscode-icons:file-type-yarn',
|
|
47
|
+
bun: 'vscode-icons:file-type-bun',
|
|
48
|
+
yml: 'vscode-icons:file-type-yaml',
|
|
49
|
+
terminal: 'i-heroicons-command-line',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const { ui } = useUI('content.prose.code.icon', undefined, config, undefined, true)
|
|
53
|
+
|
|
54
|
+
const icon = computed(() => {
|
|
55
|
+
if (props.icon) {
|
|
56
|
+
return props.icon
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const fullName = (props.filename || '').split(' ')[0] || ''
|
|
60
|
+
const filename = fullName.split('/').pop() || ''
|
|
61
|
+
|
|
62
|
+
if (ui.value[filename]) {
|
|
63
|
+
return ui.value[filename]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (filename.includes('.config') || /\w+rc/.test(filename)) {
|
|
67
|
+
return ui.value['.config']
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// if (fullName.includes('plugin')) {
|
|
71
|
+
// return ui.value['.plugin']
|
|
72
|
+
// }
|
|
73
|
+
|
|
74
|
+
const extName = filename.split('.').pop()
|
|
75
|
+
if (ui.value[extName]) {
|
|
76
|
+
return ui.value[extName]
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<template>
|
|
82
|
+
<UIcon v-if="icon" :name="icon.split(' ').pop()" dynamic />
|
|
83
|
+
</template>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<!-- eslint-disable vue/no-v-html -->
|
|
2
2
|
<template>
|
|
3
|
-
<Callout icon="i-ph-bookmark-simple-duotone" :to="to">
|
|
3
|
+
<Callout icon="i-ph-bookmark-simple-duotone" :to="to || '#'">
|
|
4
4
|
<MDCSlot unwrap="p"> Read more in <span class="font-bold" v-html="computedTitle" />. </MDCSlot>
|
|
5
5
|
</Callout>
|
|
6
6
|
</template>
|
|
@@ -16,7 +16,7 @@ import { splitByCase, upperFirst } from 'scule'
|
|
|
16
16
|
const props = defineProps({
|
|
17
17
|
to: {
|
|
18
18
|
type: String,
|
|
19
|
-
required:
|
|
19
|
+
required: false,
|
|
20
20
|
},
|
|
21
21
|
title: {
|
|
22
22
|
type: String,
|
package/app/layouts/docs.vue
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const navigation = inject<Ref<NavItem[]>>('navigation')
|
|
2
|
+
const docsNav = useDocsNav()
|
|
5
3
|
</script>
|
|
6
4
|
|
|
7
5
|
<template>
|
|
8
6
|
<UContainer>
|
|
9
7
|
<UPage>
|
|
10
8
|
<template #left>
|
|
11
|
-
<UAside>
|
|
12
|
-
<
|
|
9
|
+
<UAside :links="docsNav.links">
|
|
10
|
+
<UDivider type="dashed" class="mb-6" v-if="docsNav.activeLinks?.length" />
|
|
11
|
+
<UNavigationTree :links="docsNav.activeLinks" />
|
|
13
12
|
</UAside>
|
|
14
13
|
</template>
|
|
15
14
|
<slot />
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineNuxtModule } from 'nuxt/kit'
|
|
2
|
+
import type { DocsConfig } from '../../schema/config'
|
|
3
|
+
|
|
4
|
+
export default defineNuxtModule({
|
|
5
|
+
setup(_, nuxt) {
|
|
6
|
+
if (nuxt.options._prepare) {
|
|
7
|
+
return
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const docsConfig = (nuxt.options as any).docs as DocsConfig
|
|
11
|
+
|
|
12
|
+
const uiConfig = {
|
|
13
|
+
primary: docsConfig.themeColor || 'amber',
|
|
14
|
+
gray: 'neutral',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// if (docsConfig.themeColor) {
|
|
18
|
+
// const { getColors } = await import('theme-colors')
|
|
19
|
+
// const colors = getColors(docsConfig.themeColor)
|
|
20
|
+
// // UI
|
|
21
|
+
// // uiConfig.primary = colors['500']
|
|
22
|
+
// // Tailwind
|
|
23
|
+
// nuxt.options.tailwindcss ||= {} as any
|
|
24
|
+
// nuxt.options.tailwindcss.config ||= {}
|
|
25
|
+
// nuxt.options.tailwindcss.config.theme ||= {}
|
|
26
|
+
// nuxt.options.tailwindcss.config.theme.extend ||= {}
|
|
27
|
+
// nuxt.options.tailwindcss.config.theme.extend.colors = {
|
|
28
|
+
// ...colors,
|
|
29
|
+
// ...nuxt.options.tailwindcss.config.theme.extend.colors,
|
|
30
|
+
// }
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
nuxt.hook('ready', () => {
|
|
34
|
+
nuxt.options.appConfig.ui = {
|
|
35
|
+
...nuxt.options.appConfig.ui,
|
|
36
|
+
...uiConfig,
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
nuxt.hook('tailwindcss:config', (tailwindConfig) => {
|
|
41
|
+
const themeColor = (tailwindConfig.theme?.extend?.colors as any)?.theme?.['500']
|
|
42
|
+
if (themeColor) {
|
|
43
|
+
nuxt.options.app.head = nuxt.options.app.head || {}
|
|
44
|
+
nuxt.options.app.head.meta = nuxt.options.app.head.meta || []
|
|
45
|
+
nuxt.options.app.head.meta.push({ name: 'theme-color', content: themeColor })
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
},
|
|
49
|
+
})
|
package/app/nuxt.config.ts
CHANGED
package/app/pages/[...slug].vue
CHANGED
|
@@ -57,6 +57,10 @@ const tocLinks = computed(() =>
|
|
|
57
57
|
const scrollToTop = () => {
|
|
58
58
|
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
|
|
59
59
|
}
|
|
60
|
+
const isMobile = ref(false)
|
|
61
|
+
onMounted(() => {
|
|
62
|
+
isMobile.value = 'ontouchstart' in document.documentElement
|
|
63
|
+
})
|
|
60
64
|
</script>
|
|
61
65
|
|
|
62
66
|
<template>
|
|
@@ -64,11 +68,14 @@ const scrollToTop = () => {
|
|
|
64
68
|
<UPageHeader :title="page.title" :description="page.description" :links="page.links" :headline="headline">
|
|
65
69
|
</UPageHeader>
|
|
66
70
|
|
|
67
|
-
<div
|
|
71
|
+
<div
|
|
72
|
+
v-if="tocLinks.length > 1"
|
|
73
|
+
class="float-right mt-4 top-[calc(var(--header-height)_+_0.5rem)] z-10 flex justify-end sticky"
|
|
74
|
+
>
|
|
68
75
|
<UDropdown
|
|
69
|
-
v-if="tocLinks.length > 2"
|
|
70
76
|
:items="[[{ label: 'Return to top', click: scrollToTop }], tocLinks]"
|
|
71
77
|
:popper="{ placement: 'bottom-end' }"
|
|
78
|
+
:mode="isMobile ? 'click' : 'hover'"
|
|
72
79
|
v-model:open="tocOpen"
|
|
73
80
|
>
|
|
74
81
|
<UButton
|
|
@@ -81,6 +88,8 @@ const scrollToTop = () => {
|
|
|
81
88
|
</div>
|
|
82
89
|
|
|
83
90
|
<UPageBody prose>
|
|
91
|
+
<br v-if="tocLinks.length > 1" />
|
|
92
|
+
|
|
84
93
|
<ContentRenderer v-if="page.body" :value="page" />
|
|
85
94
|
|
|
86
95
|
<div class="space-y-6">
|
package/app/pages/index.vue
CHANGED
package/app/utils/nav.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { NavItem } from '@nuxt/content/dist/runtime/types'
|
|
2
|
+
|
|
3
|
+
export function useDocsNav() {
|
|
4
|
+
const navigation = inject<Ref<NavItem[]>>('navigation')
|
|
5
|
+
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
|
|
8
|
+
const isActive = (path: string) => route.path.startsWith(path)
|
|
9
|
+
|
|
10
|
+
const links = computed(() => {
|
|
11
|
+
return mapContentNavigation(navigation.value).map((item) => {
|
|
12
|
+
if (item.children?.length === 1) {
|
|
13
|
+
return {
|
|
14
|
+
...item,
|
|
15
|
+
...item.children[0],
|
|
16
|
+
children: undefined,
|
|
17
|
+
active: isActive(item.to as string),
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
...item,
|
|
22
|
+
label: titleCase(item.to),
|
|
23
|
+
active: isActive(item.to as string),
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
const activeLinks = computed(() => {
|
|
29
|
+
return links.value.find((l) => route.path.startsWith(l.to as string))?.children || []
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
return reactive({
|
|
33
|
+
links,
|
|
34
|
+
activeLinks,
|
|
35
|
+
})
|
|
36
|
+
}
|
package/cli/setup.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from 'node:url'
|
|
2
2
|
import { resolve } from 'node:path'
|
|
3
|
-
import { getColors } from 'theme-colors'
|
|
4
3
|
import { loadConfig, watchConfig } from 'c12'
|
|
5
4
|
|
|
6
5
|
const appDir = fileURLToPath(new URL('../app', import.meta.url))
|
|
@@ -69,15 +68,6 @@ export async function setupDocs(docsDir, opts = {}) {
|
|
|
69
68
|
routeRules: {
|
|
70
69
|
...Object.fromEntries(Object.entries(docsconfig.redirects || {}).map(([from, to]) => [from, { redirect: to }])),
|
|
71
70
|
},
|
|
72
|
-
tailwindcss: {
|
|
73
|
-
config: {
|
|
74
|
-
theme: {
|
|
75
|
-
extend: {
|
|
76
|
-
colors: docsconfig.themeColor ? { theme: getColors(docsconfig.themeColor) } : undefined,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
71
|
}
|
|
82
72
|
|
|
83
73
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "undocs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.15",
|
|
4
4
|
"repository": "unjs/undocs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"pkg-types": "^1.0.3",
|
|
52
52
|
"scule": "^1.3.0",
|
|
53
53
|
"tailwindcss": "^3.4.1",
|
|
54
|
-
"theme-colors": "^0.1.0",
|
|
55
54
|
"unctx": "^2.3.1",
|
|
56
55
|
"unstorage": "^1.10.1",
|
|
57
56
|
"vue": "^3.4.19",
|
package/app/modules/tailwind.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { defineNuxtModule } from 'nuxt/kit'
|
|
2
|
-
|
|
3
|
-
export default defineNuxtModule({
|
|
4
|
-
setup(_, nuxt) {
|
|
5
|
-
if (nuxt.options._prepare) {
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
nuxt.hook('tailwindcss:config', (tailwindConfig) => {
|
|
10
|
-
const themeColor = (tailwindConfig.theme?.extend?.colors as any)?.theme?.['500']
|
|
11
|
-
if (themeColor) {
|
|
12
|
-
nuxt.options.app.head = nuxt.options.app.head || {}
|
|
13
|
-
nuxt.options.app.head.meta = nuxt.options.app.head.meta || []
|
|
14
|
-
nuxt.options.app.head.meta.push({ name: 'theme-color', content: themeColor })
|
|
15
|
-
}
|
|
16
|
-
})
|
|
17
|
-
},
|
|
18
|
-
})
|
package/app/utils/label.ts
DELETED
|
File without changes
|