@baybreezy/docd 0.0.5 → 0.0.7
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/assets/css/tailwind.css +0 -1
- package/app/components/docs/DocsGithubLink.vue +1 -1
- package/app/components/docs/DocsThemeCustomizer.vue +41 -34
- package/app/components/docs/DocsThemeToggler.vue +1 -1
- package/modules/config.ts +14 -11
- package/modules/css.ts +21 -14
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<NuxtLink :href="github?.repo" target="_blank" rel="noopener noreferrer">
|
|
3
|
-
<UiButton
|
|
3
|
+
<UiButton size="icon-sm" variant="ghost">
|
|
4
4
|
<Icon name="simple-icons:github" />
|
|
5
5
|
</UiButton>
|
|
6
6
|
</NuxtLink>
|
|
@@ -1,41 +1,48 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<UiPopoverTrigger as-child>
|
|
6
|
-
<UiButton size="icon-sm" variant="ghost">
|
|
7
|
-
<Icon name="lucide:palette" />
|
|
8
|
-
</UiButton>
|
|
9
|
-
</UiPopoverTrigger>
|
|
10
|
-
</UiTooltipTrigger>
|
|
11
|
-
<UiPopoverContent
|
|
12
|
-
translucent
|
|
13
|
-
class="w-auto overflow-y-auto p-4"
|
|
14
|
-
side="right"
|
|
15
|
-
align="end"
|
|
16
|
-
:side-offset="8"
|
|
17
|
-
>
|
|
18
|
-
<DocsThemeCustomizerCore />
|
|
19
|
-
</UiPopoverContent>
|
|
20
|
-
<UiTooltipContent> Customize theme </UiTooltipContent>
|
|
21
|
-
</UiTooltip>
|
|
22
|
-
</UiPopover>
|
|
23
|
-
<UiDrawer v-else>
|
|
24
|
-
<UiDrawerTrigger as-child>
|
|
25
|
-
<UiButton size="icon-sm" variant="ghost">
|
|
2
|
+
<ClientOnly>
|
|
3
|
+
<template #fallback>
|
|
4
|
+
<UiButton size="icon-sm" variant="ghost" disabled>
|
|
26
5
|
<Icon name="lucide:palette" />
|
|
27
6
|
</UiButton>
|
|
28
|
-
</
|
|
29
|
-
<
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
</template>
|
|
8
|
+
<UiPopover v-if="isDesktop">
|
|
9
|
+
<UiTooltip>
|
|
10
|
+
<UiTooltipTrigger as-child>
|
|
11
|
+
<UiPopoverTrigger as-child>
|
|
12
|
+
<UiButton size="icon-sm" variant="ghost">
|
|
13
|
+
<Icon name="lucide:palette" />
|
|
14
|
+
</UiButton>
|
|
15
|
+
</UiPopoverTrigger>
|
|
16
|
+
</UiTooltipTrigger>
|
|
17
|
+
<UiPopoverContent
|
|
18
|
+
translucent
|
|
19
|
+
class="w-auto overflow-y-auto p-4"
|
|
20
|
+
side="right"
|
|
21
|
+
align="end"
|
|
22
|
+
:side-offset="8"
|
|
34
23
|
>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
<DocsThemeCustomizerCore />
|
|
25
|
+
</UiPopoverContent>
|
|
26
|
+
<UiTooltipContent> Customize theme </UiTooltipContent>
|
|
27
|
+
</UiTooltip>
|
|
28
|
+
</UiPopover>
|
|
29
|
+
<UiDrawer v-else>
|
|
30
|
+
<UiDrawerTrigger as-child>
|
|
31
|
+
<UiButton size="icon-sm" variant="ghost">
|
|
32
|
+
<Icon name="lucide:palette" />
|
|
33
|
+
</UiButton>
|
|
34
|
+
</UiDrawerTrigger>
|
|
35
|
+
<UiDrawerContent class="w-full px-4 pb-6">
|
|
36
|
+
<UiDrawerHeader>
|
|
37
|
+
<UiDrawerTitle class="sr-only">Theme Customizer</UiDrawerTitle>
|
|
38
|
+
<UiDrawerDescription class="sr-only"
|
|
39
|
+
>Pick a style and color for your components.</UiDrawerDescription
|
|
40
|
+
>
|
|
41
|
+
</UiDrawerHeader>
|
|
42
|
+
<DocsThemeCustomizerCore />
|
|
43
|
+
</UiDrawerContent>
|
|
44
|
+
</UiDrawer>
|
|
45
|
+
</ClientOnly>
|
|
39
46
|
</template>
|
|
40
47
|
|
|
41
48
|
<script lang="ts" setup>
|
package/modules/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtModule } from "@nuxt/kit";
|
|
2
|
-
import {
|
|
2
|
+
import { defu } from "defu";
|
|
3
3
|
|
|
4
4
|
import { getGitBranch, getGitEnv, getLocalGitInfo } from "../utils/git";
|
|
5
5
|
import { getPackageJsonMetadata, inferSiteURL } from "../utils/meta";
|
|
@@ -20,17 +20,20 @@ export default defineNuxtModule({
|
|
|
20
20
|
gitInfo?.name ||
|
|
21
21
|
"";
|
|
22
22
|
|
|
23
|
-
nuxt.options.vite.optimizeDeps =
|
|
23
|
+
nuxt.options.vite.optimizeDeps = defu(nuxt.options.vite.optimizeDeps, {
|
|
24
24
|
include: [
|
|
25
25
|
"mermaid",
|
|
26
26
|
"lodash-es",
|
|
27
27
|
"tailwind-variants",
|
|
28
28
|
"@baybreezy/file-extension-icon",
|
|
29
29
|
"@iconify/utils",
|
|
30
|
+
"vaul-vue",
|
|
31
|
+
"@vue/devtools-core",
|
|
32
|
+
"@vue/devtools-kit",
|
|
30
33
|
],
|
|
31
34
|
});
|
|
32
35
|
|
|
33
|
-
nuxt.options.llms =
|
|
36
|
+
nuxt.options.llms = defu(nuxt.options.llms ?? {}, {
|
|
34
37
|
domain: url,
|
|
35
38
|
title: siteName,
|
|
36
39
|
description: meta.description || "",
|
|
@@ -40,24 +43,24 @@ export default defineNuxtModule({
|
|
|
40
43
|
},
|
|
41
44
|
});
|
|
42
45
|
|
|
43
|
-
nuxt.options.app.head =
|
|
46
|
+
nuxt.options.app.head = defu(nuxt.options.app.head ?? {}, {
|
|
44
47
|
title: siteName,
|
|
45
48
|
titleTemplate: `%s - ${siteName}`,
|
|
46
|
-
} as typeof nuxt.options.app.head
|
|
49
|
+
}) as typeof nuxt.options.app.head;
|
|
47
50
|
|
|
48
|
-
nuxt.options.site =
|
|
51
|
+
nuxt.options.site = defu(nuxt.options.site ?? {}, {
|
|
49
52
|
url: url || "",
|
|
50
53
|
name: siteName,
|
|
51
54
|
debug: false,
|
|
52
55
|
}) as typeof nuxt.options.site;
|
|
53
56
|
|
|
54
57
|
if (siteName) {
|
|
55
|
-
nuxt.options.colorMode =
|
|
58
|
+
nuxt.options.colorMode = defu(nuxt.options.colorMode ?? {}, {
|
|
56
59
|
storageKey: `${siteName.toLocaleLowerCase().replace(/\s+/g, "-")}-color-mode`,
|
|
57
60
|
}) as typeof nuxt.options.colorMode;
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
nuxt.options.appConfig.docd =
|
|
63
|
+
nuxt.options.appConfig.docd = defu(nuxt.options.appConfig.docd ?? {}, {
|
|
61
64
|
github: {
|
|
62
65
|
repo: gitInfo?.url ?? url ?? "",
|
|
63
66
|
branch: getGitBranch(),
|
|
@@ -70,7 +73,7 @@ export default defineNuxtModule({
|
|
|
70
73
|
},
|
|
71
74
|
});
|
|
72
75
|
|
|
73
|
-
nuxt.options.appConfig.seo =
|
|
76
|
+
nuxt.options.appConfig.seo = defu(nuxt.options.appConfig.seo ?? {}, {
|
|
74
77
|
titleTemplate: `%s - ${siteName}`,
|
|
75
78
|
title: siteName,
|
|
76
79
|
description: meta.description || "",
|
|
@@ -80,9 +83,9 @@ export default defineNuxtModule({
|
|
|
80
83
|
nuxt.options.appConfig.docd as { ui?: { colorMode?: string } } | undefined
|
|
81
84
|
)?.ui?.colorMode;
|
|
82
85
|
if (forcedColorMode === "light" || forcedColorMode === "dark") {
|
|
83
|
-
nuxt.options.colorMode =
|
|
86
|
+
nuxt.options.colorMode = defu(
|
|
84
87
|
{ preference: forcedColorMode, fallback: forcedColorMode },
|
|
85
|
-
nuxt.options.colorMode
|
|
88
|
+
nuxt.options.colorMode ?? {}
|
|
86
89
|
) as typeof nuxt.options.colorMode;
|
|
87
90
|
}
|
|
88
91
|
},
|
package/modules/css.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
|
|
1
3
|
import { addVitePlugin, createResolver, defineNuxtModule } from "@nuxt/kit";
|
|
2
|
-
import { joinURL } from "ufo";
|
|
3
4
|
|
|
4
5
|
export default defineNuxtModule({
|
|
5
6
|
meta: {
|
|
@@ -8,24 +9,30 @@ export default defineNuxtModule({
|
|
|
8
9
|
setup(_options, nuxt) {
|
|
9
10
|
const resolver = createResolver(import.meta.url);
|
|
10
11
|
|
|
11
|
-
// Absolute path to the layer's tailwind entry —
|
|
12
|
-
//
|
|
13
|
-
const tailwindCssPath = resolver.resolve("../app/assets/css/tailwind.css");
|
|
12
|
+
// Absolute path to the layer's tailwind entry — resolved from this module's
|
|
13
|
+
// location so it stays correct whether docd is local or installed from npm.
|
|
14
|
+
const tailwindCssPath = resolver.resolve("../app/assets/css/tailwind.css").replace(/\\/g, "/");
|
|
14
15
|
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
const
|
|
16
|
+
// Absolute paths that Tailwind needs to scan.
|
|
17
|
+
const rootDir = nuxt.options.rootDir.replace(/\\/g, "/");
|
|
18
|
+
const layerAppDir = resolver.resolve("../app").replace(/\\/g, "/");
|
|
18
19
|
|
|
19
|
-
//
|
|
20
|
+
// Use the `load` hook rather than `transform` so our modified source is
|
|
21
|
+
// visible to @tailwindcss/vite's transform hook (which has enforce:"pre"
|
|
22
|
+
// and is registered earlier). Vite always runs `load` before `transform`.
|
|
20
23
|
addVitePlugin({
|
|
21
24
|
name: "docd:inject-tailwind-sources",
|
|
22
25
|
enforce: "pre",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
async load(id) {
|
|
27
|
+
const cleanId = id?.split("?")?.[0]?.replace(/\\/g, "/");
|
|
28
|
+
if (cleanId !== tailwindCssPath) return null;
|
|
29
|
+
|
|
30
|
+
const code = await readFile(tailwindCssPath, "utf8");
|
|
31
|
+
return [
|
|
32
|
+
code,
|
|
33
|
+
`@source ${JSON.stringify(`${rootDir}/**/*`)};`,
|
|
34
|
+
`@source ${JSON.stringify(`${layerAppDir}/**/*`)};`,
|
|
35
|
+
].join("\n");
|
|
29
36
|
},
|
|
30
37
|
});
|
|
31
38
|
|