@onderwijsin/nuxt-markdown-renderer 0.0.0-stage → 0.2.1

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +325 -2
  3. package/dist/metadata/runtime/app/components/renderer/MarkdownButton.vue +67 -0
  4. package/dist/metadata/runtime/app/components/renderer/MarkdownCallout.vue +115 -0
  5. package/dist/metadata/runtime/app/components/renderer/MarkdownReference.vue +33 -0
  6. package/dist/metadata/runtime/app/utils/define-editor-component-schema.ts +12 -0
  7. package/dist/metadata/schema/editor-component-schema.ts +262 -0
  8. package/dist/module.d.mts +22 -0
  9. package/dist/module.json +12 -0
  10. package/dist/module.mjs +268 -0
  11. package/dist/runtime/app/comark-plugins/video-source.d.ts +8 -0
  12. package/dist/runtime/app/comark-plugins/video-source.js +31 -0
  13. package/dist/runtime/app/components/MarkdownRenderer.d.vue.ts +12 -0
  14. package/dist/runtime/app/components/MarkdownRenderer.vue +41 -0
  15. package/dist/runtime/app/components/MarkdownRenderer.vue.d.ts +12 -0
  16. package/dist/runtime/app/components/renderer/MarkdownButton.d.vue.ts +26 -0
  17. package/dist/runtime/app/components/renderer/MarkdownButton.vue +47 -0
  18. package/dist/runtime/app/components/renderer/MarkdownButton.vue.d.ts +26 -0
  19. package/dist/runtime/app/components/renderer/MarkdownCallout.d.vue.ts +49 -0
  20. package/dist/runtime/app/components/renderer/MarkdownCallout.vue +80 -0
  21. package/dist/runtime/app/components/renderer/MarkdownCallout.vue.d.ts +49 -0
  22. package/dist/runtime/app/components/renderer/MarkdownReference.d.vue.ts +17 -0
  23. package/dist/runtime/app/components/renderer/MarkdownReference.vue +24 -0
  24. package/dist/runtime/app/components/renderer/MarkdownReference.vue.d.ts +17 -0
  25. package/dist/runtime/app/utils/component-manifest.d.ts +13 -0
  26. package/dist/runtime/app/utils/component-manifest.js +17 -0
  27. package/dist/runtime/app/utils/define-editor-component-schema.d.ts +9 -0
  28. package/dist/runtime/app/utils/define-editor-component-schema.js +3 -0
  29. package/dist/runtime/app/utils/resolve-reference-path.d.ts +7 -0
  30. package/dist/runtime/app/utils/resolve-reference-path.js +2 -0
  31. package/dist/runtime/index.css +1 -0
  32. package/dist/runtime/index.d.ts +1 -0
  33. package/dist/runtime/index.js +0 -0
  34. package/dist/runtime/server/utils/component-metadata-handler.d.ts +61 -0
  35. package/dist/runtime/server/utils/component-metadata-handler.js +17 -0
  36. package/dist/runtime/server/utils/metadata.d.ts +22 -0
  37. package/dist/runtime/server/utils/metadata.js +186 -0
  38. package/dist/runtime/shared/types.d.ts +1 -0
  39. package/dist/runtime/shared/types.js +0 -0
  40. package/dist/runtime/types/markdown-renderer.d.ts +20 -0
  41. package/dist/schema/editor-component-schema.d.ts +223 -0
  42. package/dist/schema/editor-component-schema.js +151 -0
  43. package/dist/types.d.mts +7 -0
  44. package/package.json +71 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stichting Onderwijs in
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,326 @@
1
- # Temporary Holding Version
1
+ # @onderwijsin/nuxt-markdown-renderer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Nuxt 4 module for rendering Markdown and MDC with Comark, Nuxt UI Prose, lazy application
4
+ components, and component metadata for the Directus Markdown editor.
5
+
6
+ ## Features
7
+
8
+ - Renders Markdown and MDC through the global `MarkdownRenderer` component.
9
+ - Includes `MarkdownButton`, `MarkdownCallout`, and the persisted `Reference` node.
10
+ - Discovers application renderer components through Nuxt's component registry.
11
+ - Lazily imports custom components and optionally restricts them with named component sets.
12
+ - Exposes Directus-compatible component metadata, including CORS preflight handling.
13
+ - Provides a typed compiler macro for editor labels, node types, choices, input controls, and
14
+ deprecation hints.
15
+
16
+ ## Requirements
17
+
18
+ - Nuxt `^4.0.0`
19
+ - Node.js 24 or newer
20
+ - Nuxt UI 4 and Comark are installed automatically as Nuxt module dependencies.
21
+
22
+ The renderer can be used alongside `@onderwijsin/nuxt-webmanifest` and Schema.org components without
23
+ installing `@unhead/schema-org` separately. Renderer component metadata remains available.
24
+
25
+ ## Installation
26
+
27
+ ```sh
28
+ pnpm add @onderwijsin/nuxt-markdown-renderer
29
+ ```
30
+
31
+ Register the module:
32
+
33
+ ```ts
34
+ export default defineNuxtConfig({
35
+ modules: ["@onderwijsin/nuxt-markdown-renderer"]
36
+ });
37
+ ```
38
+
39
+ Import the module stylesheet in the consuming application's main CSS file after `@nuxt/ui`:
40
+
41
+ ```css
42
+ @import "tailwindcss";
43
+ @import "@nuxt/ui";
44
+ @import "@onderwijsin/nuxt-markdown-renderer";
45
+ ```
46
+
47
+ ## Render Markdown
48
+
49
+ `MarkdownRenderer` accepts the Markdown source and an optional named component set:
50
+
51
+ ```vue
52
+ <template>
53
+ <MarkdownRenderer :value="article.content" component-set="article" />
54
+ </template>
55
+ ```
56
+
57
+ | Prop | Type | Default | Description |
58
+ | -------------- | ---------------- | ----------- | ----------------------------------------------- |
59
+ | `value` | `string` | `undefined` | Markdown or MDC source. |
60
+ | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
61
+ | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
62
+
63
+ The built-in MDC nodes are:
64
+
65
+ | Markdown node | Vue implementation | Editor label | Behavior |
66
+ | ----------------- | ------------------- | ------------ | -------------------------------------------- |
67
+ | `MarkdownButton` | `MarkdownButton` | Button | Inline Nuxt UI button or link. |
68
+ | `MarkdownCallout` | `MarkdownCallout` | Callout | Block Nuxt UI alert with editable content. |
69
+ | `Reference` | `MarkdownReference` | — | Directus item reference; excluded from menu. |
70
+
71
+ The built-in button's icon editor metadata uses the `lucide` collection by default. To offer other
72
+ icon collections in component metadata, override the relevant renderer component and define its own
73
+ `defineEditorComponentSchema` with the desired `collections` for each icon input.
74
+
75
+ For example:
76
+
77
+ ```md
78
+ ::MarkdownCallout{title="Before you continue" color="warning"} Read the
79
+ :MarkdownButton{label="documentation" to="/docs" variant="soft"}. ::
80
+ ```
81
+
82
+ ## Configuration
83
+
84
+ ```ts
85
+ export default defineNuxtConfig({
86
+ markdownRenderer: {
87
+ enabled: true,
88
+ scopeComponentMeta: true,
89
+ componentsDir: "renderer",
90
+ componentSets: {
91
+ article: ["MarkdownButton", "MarkdownCallout", "MarkdownHero"],
92
+ landing: ["MarkdownButton", "MarkdownHero"]
93
+ },
94
+ resolveReferencePath: "~/utils/resolveReferencePath",
95
+ videoBaseUrl: "https://media.example.com/assets/",
96
+ corsOrigin: "https://directus.example.com"
97
+ }
98
+ });
99
+ ```
100
+
101
+ | Option | Type | Default | Description |
102
+ | ---------------------- | -------------------------- | ------------ | ----------------------------------------------------------------- |
103
+ | `enabled` | `boolean` | `true` | Enables component, manifest, and metadata endpoint registration. |
104
+ | `scopeComponentMeta` | `boolean` | `true` | Limits global component metadata extraction to renderer sources. |
105
+ | `componentsDir` | `string` | `"renderer"` | Directory below `app/components/` containing renderer components. |
106
+ | `componentSets` | `Record<string, string[]>` | `{}` | Named allowlists used by rendering and metadata endpoints. |
107
+ | `resolveReferencePath` | `string` | unset | Nuxt-resolvable path to a default-exported Reference resolver. |
108
+ | `videoBaseUrl` | `string` | unset | Absolute base URL for relative video sources. |
109
+ | `corsOrigin` | `string \| string[]` | `"*"` | Origins allowed to call the metadata endpoint from a browser. |
110
+
111
+ A single `corsOrigin` string is accepted and normalized to an allowlist. Use `"null"` only when a
112
+ sandboxed or local client intentionally sends an opaque origin.
113
+
114
+ ## Video sources and plugins
115
+
116
+ Set `markdownRenderer.videoBaseUrl` to an absolute URL to prefix relative `video` sources:
117
+
118
+ ```md
119
+ :video{src="clip.mp4" controls}
120
+ ```
121
+
122
+ With `videoBaseUrl: "https://media.example.com/assets/"`, both `clip.mp4` and `/clip.mp4` resolve to
123
+ `https://media.example.com/assets/clip.mp4`. URLs with a protocol (including `blob:` and `data:`)
124
+ and protocol-relative URLs (`//...`) remain unchanged. The transformation only affects a `video`
125
+ node's string `src`; nested `source` elements are unchanged. Omit the option to preserve video
126
+ sources and leave the built-in plugin unloaded.
127
+
128
+ `MarkdownRenderer` also accepts `plugins?: ComarkPlugin[]` through its `plugins` prop. Pass
129
+ initialized Comark plugins; they run before the built-in video-source plugin. The renderer does not
130
+ mutate the supplied array. Built-in plugin selection and the video base URL are captured when the
131
+ renderer is created; remount it after changing the video configuration.
132
+
133
+ ## Custom renderer components
134
+
135
+ Place Vue files directly in `app/components/<componentsDir>/`. Nested files are not discovered. Nuxt
136
+ owns filename resolution and extension support; a consumer file with the same registered name
137
+ replaces a built-in component.
138
+
139
+ This `MarkdownHero.vue` example uses the typed `defineEditorComponentSchema` compiler macro:
140
+
141
+ ```vue
142
+ <script setup lang="ts">
143
+ import { defineEditorComponentSchema } from "#imports";
144
+
145
+ defineEditorComponentSchema({
146
+ label: "Hero",
147
+ description: "A prominent page introduction.",
148
+ type: "block",
149
+ properties: {
150
+ actionTo: { input: "url" },
151
+ image: { properties: { src: { input: "image" } } },
152
+ actions: {
153
+ items: {
154
+ properties: {
155
+ to: { input: "url" },
156
+ icon: { input: { type: "icon", collections: ["lucide"] } }
157
+ }
158
+ }
159
+ },
160
+ legacyTone: { deprecated: { text: "Use tone instead." } }
161
+ }
162
+ });
163
+
164
+ defineProps<{
165
+ /** Main hero heading. */
166
+ title: string;
167
+ /** Horizontal content alignment. */
168
+ align?: "left" | "center";
169
+ /** Call-to-action destination. */
170
+ actionTo?: string;
171
+ image?: { src: string; alt?: string };
172
+ actions?: { label: string; to: string; icon?: string }[];
173
+ /** Legacy color name. */
174
+ legacyTone?: string;
175
+ }>();
176
+ </script>
177
+
178
+ <template>
179
+ <section>
180
+ <h1>{{ title }}</h1>
181
+ <slot />
182
+ </section>
183
+ </template>
184
+ ```
185
+
186
+ Use the registered component name in Markdown and component sets:
187
+
188
+ ```md
189
+ ::MarkdownHero{title="Build with Markdown" align="center" action-to="https://example.com"} Editable
190
+ **Markdown** in the default slot. ::
191
+ ```
192
+
193
+ `nuxt-component-meta` infers prop types, nested object fields, array items, descriptions,
194
+ required/default state, literal unions, and JSDoc tags. The macro enriches these inferred fields
195
+ without repeating their TypeScript types:
196
+
197
+ For the module's built-in components, metadata inference reads the packaged typed Vue source. This
198
+ preserves JSDoc, defaults, slots, nested prop structure, and macro tags in installed applications as
199
+ well as the module playground.
200
+
201
+ | Field | Purpose |
202
+ | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
203
+ | `label` | Human-facing label, distinct from the Markdown node name. |
204
+ | `description` | Help text shown while choosing a component. |
205
+ | `type` | Required insertion behavior: `"block"` or `"inline"`. |
206
+ | `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
207
+ | `properties.<name>.values` | Explicit choices, particularly for imported union types. |
208
+ | `properties.<name>.input` | `"image"`/`{ type: "image" }`, `"url"`/`{ type: "url" }`, or `{ type: "icon", collections: [...] }` for a string prop. |
209
+ | `properties.<name>.properties` | Overrides for fields of an inferred object prop. |
210
+ | `properties.<name>.items` | Overrides for the inferred item of an array prop. |
211
+ | `properties.<name>.deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
212
+ | `properties.<name>.type` | Explicit `string`, `number`, `boolean`, `object`, or `array` editor type. |
213
+ | `properties.<name>.description/default/required` | Overrides the corresponding inferred metadata. |
214
+
215
+ The macro translates `input` and `deprecated` to the standard tags consumed by the Directus
216
+ extension. Special inputs use a `specialInputType` tag; icon collections appear as
217
+ `config.collections` on that tag. The string and object forms are equivalent when an input requires
218
+ no options. Only fields declared by the input's Zod config schema are accepted and carried to the
219
+ tag's `config` object. The lower-level `extendComponentMeta` macro remains available for metadata
220
+ not covered by this convenience API. Invalid macro fields, including misspelled nested fields or
221
+ unsupported input controls, produce a build warning with the failing property path; that component's
222
+ editor overrides are ignored until the schema is corrected. The `image`, `url`, and `icon` inputs
223
+ require an inferred string prop, including at nested paths. An incompatible inferred type causes the
224
+ metadata endpoint to report the component and property path as a validation error.
225
+
226
+ Use `properties` at the top level of `defineEditorComponentSchema` and for nested object fields. The
227
+ generated metadata and Directus endpoint response continue to expose component fields as `props`.
228
+
229
+ ### Component sets
230
+
231
+ Component-set values use the public Markdown node names. Passing `component-set="article"` to
232
+ `MarkdownRenderer` prevents components outside that set from resolving. The corresponding metadata
233
+ URL returns only that set. An unknown set prevents custom component resolution and its metadata URL
234
+ returns HTTP 404.
235
+
236
+ Omit `component-set` to allow every discovered renderer component.
237
+
238
+ ## Directus metadata endpoint
239
+
240
+ Configure the Directus Markdown editor with a browser-accessible URL:
241
+
242
+ ```text
243
+ https://website.example.com/api/markdown-renderer/components/article
244
+ ```
245
+
246
+ The endpoint returns a bare component array. Omit the final set name to return all discovered
247
+ components. `Reference` is deliberately omitted because the Directus editor owns that reserved node.
248
+ Both `GET` and browser `OPTIONS` preflight requests are handled.
249
+
250
+ The endpoint is public and sends no authentication challenge. CORS controls which browser origins
251
+ may read it; it is not an authorization mechanism. The default `corsOrigin: "*"` supports separate
252
+ local and production Directus installations. Configure explicit HTTPS origins when deployment policy
253
+ requires a narrower allowlist.
254
+
255
+ ## References
256
+
257
+ The built-in `MarkdownReference` renders the persisted Directus syntax `:Reference`. It displays
258
+ `text ?? label` and remains plain text unless the application supplies a route resolver:
259
+
260
+ ```ts
261
+ // app/utils/resolveReferencePath.ts
262
+ import type { ResolveReferencePath } from "@onderwijsin/nuxt-markdown-renderer/runtime";
263
+
264
+ const resolveReferencePath: ResolveReferencePath = (collection, item, _label, _text, data) => {
265
+ if (collection === "articles") return `/articles/${String(data?.slug ?? item)}`;
266
+ };
267
+
268
+ export default resolveReferencePath;
269
+ ```
270
+
271
+ The resolver receives `collection`, `item`, optional `label`, optional author-controlled `text`, and
272
+ the optional Directus source snapshot `data`. Returning a string renders a Nuxt link; returning
273
+ `undefined` keeps the display text unlinked. The module never guesses application routes.
274
+
275
+ An application can replace the built-in behavior with
276
+ `app/components/<componentsDir>/MarkdownReference.vue`. It is still exposed to Markdown as
277
+ `Reference`, preserving existing stored content.
278
+
279
+ ## Disable the module
280
+
281
+ ```ts
282
+ export default defineNuxtConfig({
283
+ markdownRenderer: { enabled: false }
284
+ });
285
+ ```
286
+
287
+ The static type declaration remains available during `nuxt prepare`, but runtime components,
288
+ auto-imports, templates, and routes are not registered.
289
+
290
+ ## Troubleshooting
291
+
292
+ | Symptom | Check |
293
+ | ------------------------------------ | --------------------------------------------------------------------------- |
294
+ | Custom component renders as Markdown | Put it directly in `app/components/<componentsDir>/` and use its Nuxt name. |
295
+ | Component is missing for one field | Include its public name in the selected `componentSets` entry. |
296
+ | Metadata URL returns 404 | The requested component-set name is not configured. |
297
+ | Directus reports a CORS failure | Add the exact Directus origin to `corsOrigin`, including scheme and port. |
298
+ | Metadata omits a custom component | Ensure the SFC is discoverable and exposes parseable component metadata. |
299
+ | Reference is not linked | Configure `resolveReferencePath` and return a route for that collection. |
300
+
301
+ ## Development
302
+
303
+ ```sh
304
+ pnpm --filter markdown-renderer-playground dev
305
+ pnpm --filter markdown-renderer-playground typecheck
306
+ pnpm --filter markdown-renderer-playground build
307
+ ```
308
+
309
+ ## Component metadata scope
310
+
311
+ `markdownRenderer.scopeComponentMeta` defaults to `true`. The application's global
312
+ `nuxt-component-meta` parser processes only built-in renderer components and direct children of
313
+ `app/components/<componentsDir>/`, using packaged typed sources for built-in metadata.
314
+
315
+ If your application uses `nuxt-component-meta` for unrelated components, retain its normal global
316
+ behavior with:
317
+
318
+ ```ts
319
+ export default defineNuxtConfig({
320
+ markdownRenderer: { scopeComponentMeta: false }
321
+ });
322
+ ```
323
+
324
+ Disabling scoping preserves your component-meta component and directory configuration while keeping
325
+ built-in renderer source enrichment. Global metadata extraction can have significantly higher build
326
+ time and memory costs.
@@ -0,0 +1,67 @@
1
+ <script setup lang="ts">
2
+ import type { ButtonProps } from "@nuxt/ui";
3
+ import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
4
+
5
+ defineEditorComponentSchema({
6
+ label: "Button",
7
+ description: "A clickable button component.",
8
+ type: "block",
9
+ properties: {
10
+ color: {
11
+ values: [
12
+ "primary",
13
+ "secondary",
14
+ "success",
15
+ "info",
16
+ "warning",
17
+ "error",
18
+ "neutral"
19
+ ] satisfies Array<ButtonProps["color"]>
20
+ },
21
+ variant: {
22
+ values: ["solid", "outline", "soft", "subtle", "ghost", "link"] satisfies Array<
23
+ ButtonProps["variant"]
24
+ >
25
+ },
26
+ size: {
27
+ values: ["xs", "sm", "md", "lg", "xl"] satisfies Array<ButtonProps["size"]>
28
+ },
29
+ icon: {
30
+ input: {
31
+ type: "icon",
32
+ collections: ["lucide"]
33
+ }
34
+ }
35
+ }
36
+ });
37
+
38
+ withDefaults(
39
+ defineProps<{
40
+ /** Label displayed inside the button. */
41
+ label: string;
42
+ /** Link destination. Use either full URL or internal route path. */
43
+ to: string;
44
+ /** The color tone of the button. */
45
+ color?: ButtonProps["color"];
46
+ /** The visual style variant of the button. */
47
+ variant?: ButtonProps["variant"];
48
+ /** The size of the button. */
49
+ size?: ButtonProps["size"];
50
+ /** The icon displayed inside the button. */
51
+ icon?: string;
52
+ /** Whether the icon should be displayed after the label. */
53
+ trailing?: boolean;
54
+ /** Whether the button should trigger a download of the linked resource. */
55
+ download?: boolean;
56
+ }>(),
57
+ {
58
+ color: "primary",
59
+ variant: "soft",
60
+ size: "md"
61
+ }
62
+ );
63
+ </script>
64
+
65
+ <template>
66
+ <UButton v-bind="$props" />
67
+ </template>
@@ -0,0 +1,115 @@
1
+ <script setup lang="ts">
2
+ import type { AlertProps, ButtonProps } from "@nuxt/ui";
3
+ import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
4
+
5
+ defineEditorComponentSchema({
6
+ label: "Callout",
7
+ description: "A component used to highlight important information.",
8
+ type: "block",
9
+ properties: {
10
+ color: {
11
+ values: [
12
+ "primary",
13
+ "secondary",
14
+ "success",
15
+ "info",
16
+ "warning",
17
+ "error",
18
+ "neutral"
19
+ ] satisfies Array<AlertProps["color"]>
20
+ },
21
+ variant: {
22
+ values: ["solid", "outline", "soft", "subtle"] satisfies Array<AlertProps["variant"]>
23
+ },
24
+ icon: {
25
+ input: {
26
+ type: "icon",
27
+ collections: ["lucide"]
28
+ }
29
+ },
30
+ orientation: {
31
+ values: ["horizontal", "vertical"] satisfies Array<AlertProps["orientation"]>
32
+ },
33
+ actions: {
34
+ type: "array",
35
+ items: {
36
+ type: "object",
37
+ properties: {
38
+ color: {
39
+ values: [
40
+ "primary",
41
+ "secondary",
42
+ "success",
43
+ "info",
44
+ "warning",
45
+ "error",
46
+ "neutral"
47
+ ] satisfies Array<ButtonProps["color"]>
48
+ },
49
+ variant: {
50
+ values: ["solid", "outline", "soft", "subtle", "ghost", "link"] satisfies Array<
51
+ ButtonProps["variant"]
52
+ >
53
+ },
54
+ size: {
55
+ values: ["xs", "sm", "md", "lg", "xl"] satisfies Array<ButtonProps["size"]>
56
+ },
57
+ icon: {
58
+ input: {
59
+ type: "icon",
60
+ collections: ["lucide"]
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ });
68
+
69
+ withDefaults(
70
+ defineProps<{
71
+ /** Callout title. */
72
+ title?: string;
73
+ /** The color tone of the callout. */
74
+ color?: AlertProps["color"];
75
+ /** The visual style variant of the callout. */
76
+ variant?: AlertProps["variant"];
77
+ /** Optional Iconify icon name. */
78
+ icon?: string;
79
+ /** The orientation of the callout. Determines the position of the actions. */
80
+ orientation?: AlertProps["orientation"];
81
+ /** Optional call-to-action buttons. */
82
+ actions?: {
83
+ /** Label displayed inside the button. */
84
+ label: string;
85
+ /** Link destination. Use either full URL or internal route path. */
86
+ to: string;
87
+ /** The color tone of the button. */
88
+ color?: ButtonProps["color"];
89
+ /** The visual style variant of the button. */
90
+ variant?: ButtonProps["variant"];
91
+ /** The size of the button. */
92
+ size?: ButtonProps["size"];
93
+ /** The icon displayed inside the button. */
94
+ icon?: string;
95
+ /** Whether the icon should be displayed after the label. */
96
+ trailing?: boolean;
97
+ /** Whether the button should trigger a download of the linked resource. */
98
+ download?: boolean;
99
+ }[];
100
+ }>(),
101
+ {
102
+ color: "primary",
103
+ variant: "soft",
104
+ orientation: "vertical"
105
+ }
106
+ );
107
+ </script>
108
+
109
+ <template>
110
+ <UAlert v-bind="$props">
111
+ <template v-if="$slots.description" #description>
112
+ <slot name="description" />
113
+ </template>
114
+ </UAlert>
115
+ </template>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+
4
+ import resolveReferencePath from "#markdown-renderer/reference-resolver";
5
+
6
+ const props = defineProps<{
7
+ /** Directus collection name. */
8
+ collection: string;
9
+ /** Referenced Directus item primary key. */
10
+ item: string;
11
+ /** Source display label. */
12
+ label?: string;
13
+ /** Author-controlled display text. */
14
+ text?: string;
15
+ /** Iconify icon as collection:name. */
16
+ icon?: string;
17
+ /** Reference source snapshot. */
18
+ data?: Record<string, unknown>;
19
+ }>();
20
+
21
+ const displayText = computed(() => props.text ?? props.label ?? "");
22
+ const path = computed(() =>
23
+ resolveReferencePath(props.collection, props.item, props.label, props.text, props.data)
24
+ );
25
+ </script>
26
+
27
+ <template>
28
+ <ULink v-if="path" variant="link" :to="path" :icon="icon" class="text-primary underline">
29
+ <UIcon v-if="icon" :name="icon" class="mr-1 align-[-0.125em]" />
30
+ <span>{{ displayText }}</span>
31
+ </ULink>
32
+ <span v-else>{{ displayText }}</span>
33
+ </template>
@@ -0,0 +1,12 @@
1
+ import type { EditorComponentInput } from "../../../schema/editor-component-schema";
2
+
3
+ /**
4
+ * Defines editor metadata for a Markdown component.
5
+ *
6
+ * This is a compiler macro registered with `nuxt-component-meta`; its call is extracted at build
7
+ * time. The implementation is intentionally inert in case tooling evaluates the module directly.
8
+ * @param metadata Markdown editor metadata extracted during the Nuxt build.
9
+ */
10
+ export function defineEditorComponentSchema(metadata: EditorComponentInput): void {
11
+ void metadata;
12
+ }