@baybreezy/docd 0.0.4 → 0.0.6

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.
@@ -1,6 +1,5 @@
1
1
  @import "tailwindcss";
2
2
  @import "tw-animate-css";
3
- @source "../../../../";
4
3
 
5
4
  @config "../../../tailwind.config.cjs";
6
5
 
@@ -20,6 +20,9 @@ export function useDocd() {
20
20
  const github = computed(
21
21
  () => ((appConfig.docd as DocdConfig | undefined)?.github ?? {}) as DocdGithubConfig
22
22
  );
23
+ const hasGithub = computed(
24
+ () => !!(github.value?.repo && github.value?.branch && github.value?.contentDir)
25
+ );
23
26
 
24
27
  /* =====================================
25
28
  = Footer =
@@ -82,6 +85,7 @@ export function useDocd() {
82
85
  isDashed,
83
86
  extraLinks,
84
87
  github,
88
+ hasGithub,
85
89
  hideSearch,
86
90
  // transition
87
91
  activeName,
@@ -22,11 +22,11 @@
22
22
  class="mt-auto flex h-(--header-height) items-center justify-between gap-3 border-t px-2"
23
23
  :class="isDashed ? 'border-dashed' : ''"
24
24
  >
25
- <template v-if="github">
25
+ <template v-if="hasGithub">
26
26
  <DocsGithubLink />
27
27
  </template>
28
28
  <div class="ml-auto flex items-center gap-1.5">
29
- <template v-if="github && (!hideThemeCustomizer || !hideLightDarkToggle)">
29
+ <template v-if="hasGithub && (!hideThemeCustomizer || !hideLightDarkToggle)">
30
30
  <UiDivider
31
31
  :type="isDashed ? 'dashed' : 'solid'"
32
32
  orientation="vertical"
@@ -60,5 +60,6 @@
60
60
 
61
61
  <script lang="ts" setup>
62
62
  const { navigation } = await useDocPage();
63
- const { isDashed, github, hideSearch, hideLightDarkToggle, hideThemeCustomizer } = useDocd();
63
+ const { isDashed, github, hasGithub, hideSearch, hideLightDarkToggle, hideThemeCustomizer } =
64
+ useDocd();
64
65
  </script>
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 — this is the file that owns
12
- // `@import "tailwindcss"` and therefore controls Tailwind's scanner.
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
- // The consuming app's content directory. We convert to forward-slashes so
16
- // the injected @source glob works on Windows too.
17
- const contentDir = joinURL(nuxt.options.rootDir, "content").replace(/\\/g, "/");
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
- // Inject `@source <contentDir>/**/*` into tailwind.css
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
- transform(code: string, id: string) {
24
- if (id.split("?")[0] !== tailwindCssPath) return null;
25
- return {
26
- code: `${code}\n@source ${JSON.stringify(`${contentDir}/**/*`)};`,
27
- map: null,
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baybreezy/docd",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "A Nuxt layer for building documentation sites with UI Thing.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,7 +33,7 @@
33
33
  "@baybreezy/file-extension-icon": "^0.0.4",
34
34
  "@iconify-json/lucide": "^1.2.103",
35
35
  "@iconify-json/simple-icons": "^1.2.79",
36
- "@iconify/utils": "^3.1.0",
36
+ "@iconify/utils": "^3.1.1",
37
37
  "@morev/vue-transitions": "^3.0.5",
38
38
  "@nuxt/content": "3.13.0",
39
39
  "@nuxt/fonts": "^0.14.0",