@baybreezy/docd 0.0.9 → 0.0.11
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.
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
*/
|
|
46
46
|
export const fieldStyles = tv({
|
|
47
47
|
slots: {
|
|
48
|
-
base: "flex flex-col gap-2
|
|
48
|
+
base: "flex flex-col gap-2 p-4",
|
|
49
49
|
name: "flex flex-wrap items-center gap-2",
|
|
50
50
|
nameText: "font-semibold text-foreground",
|
|
51
51
|
typeBadge: "rounded-md px-1.5 py-0.5 text-[11px]",
|
|
@@ -4,8 +4,6 @@ import { addTemplate, createResolver, defineNuxtModule, logger, updateTemplates
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
appendComponentApiBlocks,
|
|
7
|
-
builtInComponentApiItems,
|
|
8
|
-
isBuiltInProseDocFile,
|
|
9
7
|
projectComponentApiConfig,
|
|
10
8
|
warnForMissingComponentPaths,
|
|
11
9
|
withAutoTitles,
|
|
@@ -84,21 +82,6 @@ export default defineNuxtModule({
|
|
|
84
82
|
warn: (message: string) => log.warn(message),
|
|
85
83
|
};
|
|
86
84
|
|
|
87
|
-
if (isBuiltInProseDocFile(event.content)) {
|
|
88
|
-
const { heading, items, explicit } = builtInComponentApiItems(event.content, context);
|
|
89
|
-
|
|
90
|
-
if (!items.length) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (explicit) {
|
|
95
|
-
warnForMissingComponentPaths(event.content, items, context);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
event.content = await appendComponentApiBlocks(event.content, items, heading);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
85
|
const componentApi = projectComponentApiConfig(event.content);
|
|
103
86
|
|
|
104
87
|
if (!componentApi || componentApi === false) {
|
package/package.json
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import { basename, extname } from "node:path";
|
|
3
2
|
|
|
4
3
|
import { parseMarkdown } from "@nuxtjs/mdc/runtime";
|
|
5
4
|
|
|
6
5
|
import {
|
|
7
|
-
BUILT_IN_PROSE_COMPONENT_API_REGISTRY,
|
|
8
6
|
DEFAULT_COMPONENT_API_LAYOUT,
|
|
9
|
-
DEFAULT_COMPONENT_API_SECTIONS,
|
|
10
7
|
componentLabelFromPath,
|
|
11
8
|
componentNameFromPath,
|
|
12
|
-
inferredBuiltInProseComponentPathFromSlug,
|
|
13
9
|
normalizeComponentApiConfig,
|
|
14
|
-
normalizeComponentApiLayout,
|
|
15
|
-
normalizeComponentApiSections,
|
|
16
|
-
type BuiltInComponentApiRegistryItem,
|
|
17
10
|
type NormalizedComponentApiItem,
|
|
18
11
|
} from "./component-api";
|
|
19
12
|
import { resolveComponentApiSourcePath } from "./component-api-discovery";
|
|
@@ -103,62 +96,6 @@ export function withAutoTitles(items: NormalizedComponentApiItem[]) {
|
|
|
103
96
|
}));
|
|
104
97
|
}
|
|
105
98
|
|
|
106
|
-
function registryItemsToNormalizedItems(
|
|
107
|
-
items: readonly BuiltInComponentApiRegistryItem[],
|
|
108
|
-
defaults: Pick<NormalizedComponentApiItem, "layout" | "sections">
|
|
109
|
-
) {
|
|
110
|
-
return items.map(
|
|
111
|
-
(item) =>
|
|
112
|
-
({
|
|
113
|
-
path: item.path,
|
|
114
|
-
title: item.title,
|
|
115
|
-
layout: normalizeComponentApiLayout(item.layout, defaults.layout),
|
|
116
|
-
sections: normalizeComponentApiSections(item.sections, defaults.sections),
|
|
117
|
-
}) satisfies NormalizedComponentApiItem
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function inferredItem(
|
|
122
|
-
slug: string,
|
|
123
|
-
defaults: Pick<NormalizedComponentApiItem, "layout" | "sections">,
|
|
124
|
-
context: ComponentApiTransformerContext
|
|
125
|
-
) {
|
|
126
|
-
const inferredPath = inferredBuiltInProseComponentPathFromSlug(slug);
|
|
127
|
-
const resolvedPath = resolveComponentApiSourcePath({
|
|
128
|
-
rootDir: context.rootDir,
|
|
129
|
-
layerRoot: context.layerRoot,
|
|
130
|
-
path: inferredPath,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
if (!existsSync(resolvedPath.absolutePath)) {
|
|
134
|
-
return [];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return [
|
|
138
|
-
{
|
|
139
|
-
path: inferredPath,
|
|
140
|
-
layout: defaults.layout,
|
|
141
|
-
sections: [...defaults.sections],
|
|
142
|
-
} satisfies NormalizedComponentApiItem,
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function defaultItemSettings(config: ReturnType<typeof normalizeComponentApiConfig>) {
|
|
147
|
-
if (config && config !== false) {
|
|
148
|
-
return {
|
|
149
|
-
heading: config.heading,
|
|
150
|
-
layout: config.layout,
|
|
151
|
-
sections: config.sections,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
heading: undefined,
|
|
157
|
-
layout: DEFAULT_COMPONENT_API_LAYOUT,
|
|
158
|
-
sections: [...DEFAULT_COMPONENT_API_SECTIONS],
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
99
|
function buildComponentApiBlockSource(item: NormalizedComponentApiItem, title?: string) {
|
|
163
100
|
const props = [`path="${escapeMdcProp(item.path)}"`];
|
|
164
101
|
|
|
@@ -314,67 +251,10 @@ function appendTocLinks(
|
|
|
314
251
|
};
|
|
315
252
|
}
|
|
316
253
|
|
|
317
|
-
export function isBuiltInProseDocFile(file: ComponentApiTransformerContent) {
|
|
318
|
-
return /^docs\/4\.prose\/.+\.md$/i.test(fileId(file));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export function builtInProseDocSlug(file: ComponentApiTransformerContent) {
|
|
322
|
-
return basename(fileId(file), extname(fileId(file)));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
254
|
export function projectComponentApiConfig(file: ComponentApiTransformerContent) {
|
|
326
255
|
return normalizeComponentApiConfig(file.componentApi);
|
|
327
256
|
}
|
|
328
257
|
|
|
329
|
-
export function builtInComponentApiItems(
|
|
330
|
-
file: ComponentApiTransformerContent,
|
|
331
|
-
context: ComponentApiTransformerContext
|
|
332
|
-
) {
|
|
333
|
-
const config = normalizeComponentApiConfig(file.componentApi);
|
|
334
|
-
|
|
335
|
-
if (config === false) {
|
|
336
|
-
return {
|
|
337
|
-
heading: undefined,
|
|
338
|
-
items: [] as NormalizedComponentApiItem[],
|
|
339
|
-
explicit: false,
|
|
340
|
-
};
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (config?.hasExplicitComponents) {
|
|
344
|
-
return {
|
|
345
|
-
heading: config.heading,
|
|
346
|
-
items: withAutoTitles(config.components),
|
|
347
|
-
explicit: true,
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const slug = builtInProseDocSlug(file);
|
|
352
|
-
const defaults = defaultItemSettings(config);
|
|
353
|
-
const registryEntry = BUILT_IN_PROSE_COMPONENT_API_REGISTRY[slug];
|
|
354
|
-
|
|
355
|
-
if (registryEntry === false) {
|
|
356
|
-
return {
|
|
357
|
-
heading: defaults.heading,
|
|
358
|
-
items: [] as NormalizedComponentApiItem[],
|
|
359
|
-
explicit: false,
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (Array.isArray(registryEntry)) {
|
|
364
|
-
return {
|
|
365
|
-
heading: defaults.heading,
|
|
366
|
-
items: withAutoTitles(registryItemsToNormalizedItems(registryEntry, defaults)),
|
|
367
|
-
explicit: false,
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return {
|
|
372
|
-
heading: defaults.heading,
|
|
373
|
-
items: inferredItem(slug, defaults, context),
|
|
374
|
-
explicit: false,
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
|
|
378
258
|
export function warnForMissingComponentPaths(
|
|
379
259
|
file: ComponentApiTransformerContent,
|
|
380
260
|
items: NormalizedComponentApiItem[],
|
package/utils/component-api.ts
CHANGED
|
@@ -36,25 +36,25 @@ export const BUILT_IN_PROSE_COMPONENT_API_REGISTRY: Record<
|
|
|
36
36
|
false | readonly BuiltInComponentApiRegistryItem[]
|
|
37
37
|
> = {
|
|
38
38
|
field: [
|
|
39
|
-
{ path: "app/components/content/prose/ProseField.
|
|
40
|
-
{ path: "app/components/content/prose/ProseFieldGroup.
|
|
39
|
+
{ path: "app/components/content/prose/ProseField.vue" },
|
|
40
|
+
{ path: "app/components/content/prose/ProseFieldGroup.vue" },
|
|
41
41
|
],
|
|
42
42
|
images: [
|
|
43
|
-
{ path: "app/components/content/prose/ProseImg.
|
|
44
|
-
{ path: "app/components/content/prose/ProseColorModeImage.
|
|
43
|
+
{ path: "app/components/content/prose/ProseImg.vue" },
|
|
44
|
+
{ path: "app/components/content/prose/ProseColorModeImage.vue" },
|
|
45
45
|
],
|
|
46
46
|
"icon-list": [
|
|
47
|
-
{ path: "app/components/content/prose/ProseIconList.
|
|
48
|
-
{ path: "app/components/content/prose/ProseLi.
|
|
47
|
+
{ path: "app/components/content/prose/ProseIconList.vue" },
|
|
48
|
+
{ path: "app/components/content/prose/ProseLi.vue" },
|
|
49
49
|
],
|
|
50
50
|
"package-manager": [
|
|
51
|
-
{ path: "app/components/content/prose/ProsePmInstall.
|
|
52
|
-
{ path: "app/components/content/prose/ProsePmRun.
|
|
53
|
-
{ path: "app/components/content/prose/ProsePmX.
|
|
51
|
+
{ path: "app/components/content/prose/ProsePmInstall.vue" },
|
|
52
|
+
{ path: "app/components/content/prose/ProsePmRun.vue" },
|
|
53
|
+
{ path: "app/components/content/prose/ProsePmX.vue" },
|
|
54
54
|
],
|
|
55
55
|
steps: [
|
|
56
|
-
{ path: "app/components/content/prose/ProseSteps.
|
|
57
|
-
{ path: "app/components/content/prose/ProseStep.
|
|
56
|
+
{ path: "app/components/content/prose/ProseSteps.vue" },
|
|
57
|
+
{ path: "app/components/content/prose/ProseStep.vue" },
|
|
58
58
|
],
|
|
59
59
|
"code-snippet": false,
|
|
60
60
|
typography: false,
|
|
@@ -125,7 +125,7 @@ export function componentNameFromSlug(slug: string) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
export function inferredBuiltInProseComponentPathFromSlug(slug: string) {
|
|
128
|
-
return `${BUILT_IN_PROSE_COMPONENT_ROOT}${componentNameFromSlug(slug)}.
|
|
128
|
+
return `${BUILT_IN_PROSE_COMPONENT_ROOT}${componentNameFromSlug(slug)}.vue`;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
export function normalizeComponentApiLayout(
|