@baybreezy/docd 0.1.4 → 0.1.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.
@@ -37,7 +37,7 @@
37
37
  target="_blank"
38
38
  variant="outline"
39
39
  size="md"
40
- class="transition-colors duration-300"
40
+ class="gap-1.5 transition-colors duration-300 [&>svg]:size-3.5"
41
41
  >
42
42
  <Icon
43
43
  v-if="link?.icon"
@@ -1,4 +1,4 @@
1
- import type { Collections, ContentNavigationItem } from "@nuxt/content";
1
+ import type { Collections, ContentNavigationItem, PageCollectionItemBase } from "@nuxt/content";
2
2
  import { findPageHeadline } from "@nuxt/content/utils";
3
3
  import { kebabCase } from "lodash-es";
4
4
 
@@ -9,16 +9,16 @@ export const useDocPage = async () => {
9
9
  const isLandingRoute = route.path === "/";
10
10
 
11
11
  const [{ data: page }, { data: surround }, { data: navigation }] = await Promise.all([
12
- useAsyncData(
12
+ useAsyncData<PageCollectionItemBase | null>(
13
13
  kebabCase(route.path) || "root",
14
14
  () =>
15
15
  isLandingRoute
16
- ? queryCollection("landing" as keyof Collections)
16
+ ? (queryCollection("landing" as keyof Collections)
17
17
  .path(route.path)
18
- .first()
19
- : queryCollection("docs" as keyof Collections)
18
+ .first() as Promise<PageCollectionItemBase | null>)
19
+ : (queryCollection("docs" as keyof Collections)
20
20
  .path(route.path)
21
- .first(),
21
+ .first() as Promise<PageCollectionItemBase | null>),
22
22
  { watch: [() => route.path] }
23
23
  ),
24
24
  useAsyncData(
@@ -36,7 +36,7 @@ export const useDocPage = async () => {
36
36
  ),
37
37
  useAsyncData(
38
38
  () => `navigation_docs`,
39
- () => queryCollectionNavigation("docs" as keyof Collections),
39
+ () => queryCollectionNavigation("docs" as keyof Collections, ["label", "target"]),
40
40
  {
41
41
  watch: [() => route.path],
42
42
  transform: (data: ContentNavigationItem[]) =>
package/content.config.ts CHANGED
@@ -50,6 +50,7 @@ const baseSchema = z.object({
50
50
 
51
51
  const docsSchema = baseSchema.extend({
52
52
  label: z.string().optional(),
53
+ target: z.string().optional(),
53
54
  layout: z.string().default("docs").optional(),
54
55
  });
55
56
 
@@ -29,7 +29,7 @@ export default defineNuxtModule({
29
29
  async setup(_, nuxt) {
30
30
  const resolver = createResolver(import.meta.url);
31
31
  const layerRoot = resolver.resolve("..");
32
- const { componentsDir, outputFile, cacheDir } = resolveProseComponentPaths({
32
+ const { outputFile, cacheDir } = resolveProseComponentPaths({
33
33
  rootDir: nuxt.options.rootDir,
34
34
  layerRoot,
35
35
  });
@@ -61,7 +61,6 @@ export default defineNuxtModule({
61
61
  manifest = await generateProseComponentMeta({
62
62
  rootDir: nuxt.options.rootDir,
63
63
  layerRoot,
64
- componentsDir,
65
64
  outputFile,
66
65
  cache: true,
67
66
  cacheDir,
@@ -101,7 +100,6 @@ export default defineNuxtModule({
101
100
  });
102
101
 
103
102
  nuxt.hook("builder:watch", async (_event, changedPath) => {
104
- const normalizedComponentsDir = normalizeFsPath(componentsDir);
105
103
  const normalizedContentDir = normalizeFsPath(contentDir);
106
104
  const candidates = [
107
105
  normalizeFsPath(changedPath),
@@ -109,9 +107,6 @@ export default defineNuxtModule({
109
107
  normalizeFsPath(resolvePath(layerRoot, changedPath)),
110
108
  ];
111
109
 
112
- const matchesProseComponent = candidates.some(
113
- (candidate) => candidate.endsWith(".vue") && candidate.startsWith(normalizedComponentsDir)
114
- );
115
110
  const matchesWatchedProjectComponent = candidates.some((candidate) =>
116
111
  watchedProjectComponentFiles.has(candidate)
117
112
  );
@@ -119,7 +114,7 @@ export default defineNuxtModule({
119
114
  (candidate) => candidate.endsWith(".md") && candidate.startsWith(normalizedContentDir)
120
115
  );
121
116
 
122
- if (!matchesProseComponent && !matchesWatchedProjectComponent && !matchesContentFrontmatter) {
117
+ if (!matchesWatchedProjectComponent && !matchesContentFrontmatter) {
123
118
  return;
124
119
  }
125
120
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@baybreezy/docd",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "A Nuxt layer for building documentation sites with UI Thing.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
2
+ import { mkdir, stat, writeFile } from "node:fs/promises";
3
3
  import { cpus } from "node:os";
4
- import { dirname, join, relative, resolve } from "node:path";
4
+ import { dirname, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { Worker } from "node:worker_threads";
7
7
 
@@ -110,7 +110,6 @@ export interface ProseComponentMetaSource {
110
110
  export interface GenerateProseComponentMetaOptions {
111
111
  rootDir: string;
112
112
  layerRoot: string;
113
- componentsDir: string;
114
113
  outputFile: string;
115
114
  cache?: boolean;
116
115
  cacheDir?: string;
@@ -232,26 +231,6 @@ async function runInWorkers(
232
231
  }
233
232
  }
234
233
 
235
- async function listVueFiles(dir: string): Promise<string[]> {
236
- const files: string[] = [];
237
- const entries = await readdir(dir, { withFileTypes: true });
238
-
239
- for (const entry of entries) {
240
- const fullPath = join(dir, entry.name);
241
-
242
- if (entry.isDirectory()) {
243
- files.push(...(await listVueFiles(fullPath)));
244
- continue;
245
- }
246
-
247
- if (entry.isFile() && fullPath.endsWith(".vue")) {
248
- files.push(fullPath);
249
- }
250
- }
251
-
252
- return files.sort((a, b) => a.localeCompare(b));
253
- }
254
-
255
234
  function readExistingManifest(outputFile: string): ProseComponentMetaManifest {
256
235
  if (!existsSync(outputFile)) {
257
236
  return EMPTY_PROSE_COMPONENT_META_MANIFEST;
@@ -273,19 +252,10 @@ export async function generateProseComponentMeta(
273
252
  options: GenerateProseComponentMetaOptions
274
253
  ): Promise<ProseComponentMetaManifest> {
275
254
  const previousManifest = readExistingManifest(options.outputFile);
276
- const builtInComponentFiles = await listVueFiles(options.componentsDir);
277
255
  const componentSources = new Map<string, ProseComponentMetaSource>();
278
256
  const components: Record<string, ProseComponentMetaEntry> = {};
279
257
  const sourceHashes: Record<string, string> = {};
280
258
 
281
- for (const componentPath of builtInComponentFiles) {
282
- const manifestPath = normalizeComponentMetaPath(relative(options.layerRoot, componentPath));
283
- componentSources.set(manifestPath, {
284
- absolutePath: componentPath,
285
- manifestPath,
286
- });
287
- }
288
-
289
259
  for (const component of options.additionalComponents || []) {
290
260
  componentSources.set(component.manifestPath, component);
291
261
  }