undocs 0.2.13 → 0.2.14
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 +5 -2
- package/app/components/NavigationTree.vue +22 -0
- package/app/components/global/ProseCodeIcon.vue +83 -0
- package/app/components/global/ReadMore.vue +1 -1
- package/app/layouts/docs.vue +2 -6
- package/app/modules/theme.ts +49 -0
- package/app/nuxt.config.ts +1 -4
- package/app/pages/[...slug].vue +6 -1
- package/cli/setup.mjs +0 -10
- package/package.json +1 -2
- package/app/modules/tailwind.ts +0 -18
- /package/schema/{config.ts → config.schema.ts} +0 -0
package/app/.unjs/app.config.ts
CHANGED
|
@@ -7,6 +7,8 @@ const appConfig = useAppConfig()
|
|
|
7
7
|
|
|
8
8
|
const { metaSymbol } = useShortcuts()
|
|
9
9
|
|
|
10
|
+
const route = useRoute()
|
|
11
|
+
|
|
10
12
|
const navLinks = computed(() => {
|
|
11
13
|
// console.log(mapContentNavigation(navigation.value))
|
|
12
14
|
// console.log(JSON.parse(JSON.stringify(navigation.value, null, 2)))
|
|
@@ -18,6 +20,7 @@ const navLinks = computed(() => {
|
|
|
18
20
|
return {
|
|
19
21
|
label: toLabel(nav._path.substring(1)),
|
|
20
22
|
to: nav._path,
|
|
23
|
+
active: route.path.startsWith(nav._path),
|
|
21
24
|
}
|
|
22
25
|
})
|
|
23
26
|
.filter(Boolean)
|
|
@@ -40,7 +43,7 @@ const navLinks = computed(() => {
|
|
|
40
43
|
</template>
|
|
41
44
|
|
|
42
45
|
<template #right>
|
|
43
|
-
<UHeaderLinks :links="navLinks" class="mr-4" v-if="navLinks.length > 1" />
|
|
46
|
+
<UHeaderLinks :links="navLinks" class="hidden sm:flex mr-4" v-if="navLinks.length > 1" />
|
|
44
47
|
|
|
45
48
|
<UTooltip class="lg:hidden" text="Search" :shortcuts="[metaSymbol, 'K']">
|
|
46
49
|
<UContentSearchButton :label="null" />
|
|
@@ -52,7 +55,7 @@ const navLinks = computed(() => {
|
|
|
52
55
|
</template>
|
|
53
56
|
|
|
54
57
|
<template #panel>
|
|
55
|
-
<
|
|
58
|
+
<NavigationTree />
|
|
56
59
|
</template>
|
|
57
60
|
</UHeader>
|
|
58
61
|
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NavItem } from '@nuxt/content/dist/runtime/types'
|
|
3
|
+
|
|
4
|
+
const navigation = inject<Ref<NavItem[]>>('navigation')
|
|
5
|
+
|
|
6
|
+
const navigationLinks = computed(() => {
|
|
7
|
+
return mapContentNavigation(navigation.value).map((item) => {
|
|
8
|
+
if (item.children?.length === 1) {
|
|
9
|
+
return {
|
|
10
|
+
...item,
|
|
11
|
+
...item.children[0],
|
|
12
|
+
children: undefined,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return item
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<UNavigationTree :links="navigationLinks" default-open :multiple="false" />
|
|
22
|
+
</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>
|
package/app/layouts/docs.vue
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { NavItem } from '@nuxt/content/dist/runtime/types'
|
|
3
|
-
|
|
4
|
-
const navigation = inject<Ref<NavItem[]>>('navigation')
|
|
5
|
-
</script>
|
|
1
|
+
<script setup lang="ts"></script>
|
|
6
2
|
|
|
7
3
|
<template>
|
|
8
4
|
<UContainer>
|
|
9
5
|
<UPage>
|
|
10
6
|
<template #left>
|
|
11
7
|
<UAside>
|
|
12
|
-
<
|
|
8
|
+
<NavigationTree />
|
|
13
9
|
</UAside>
|
|
14
10
|
</template>
|
|
15
11
|
<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,12 @@ const scrollToTop = () => {
|
|
|
64
68
|
<UPageHeader :title="page.title" :description="page.description" :links="page.links" :headline="headline">
|
|
65
69
|
</UPageHeader>
|
|
66
70
|
|
|
67
|
-
<div class="mt-4 top-[calc(var(--header-height)_+_0.5rem)] z-10 flex justify-end
|
|
71
|
+
<div class="float-right mt-4 top-[calc(var(--header-height)_+_0.5rem)] z-10 flex justify-end sticky">
|
|
68
72
|
<UDropdown
|
|
69
73
|
v-if="tocLinks.length > 2"
|
|
70
74
|
:items="[[{ label: 'Return to top', click: scrollToTop }], tocLinks]"
|
|
71
75
|
:popper="{ placement: 'bottom-end' }"
|
|
76
|
+
:mode="isMobile ? 'click' : 'hover'"
|
|
72
77
|
v-model:open="tocOpen"
|
|
73
78
|
>
|
|
74
79
|
<UButton
|
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.14",
|
|
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
|
-
})
|
|
File without changes
|