@onderwijsin/nuxt-markdown-renderer 0.3.0 → 0.5.0

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 (35) hide show
  1. package/README.md +129 -46
  2. package/dist/metadata/runtime/app/components/renderer/MarkdownAnchor.vue +1 -0
  3. package/dist/metadata/runtime/app/components/renderer/MarkdownItemList.vue +1 -0
  4. package/dist/metadata/runtime/shared/types.ts +4 -4
  5. package/dist/metadata/schema/editor-component-schema.ts +25 -4
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +18 -3
  8. package/dist/runtime/app/components/MarkdownRenderer.d.vue.ts +4 -0
  9. package/dist/runtime/app/components/MarkdownRenderer.vue +27 -2
  10. package/dist/runtime/app/components/MarkdownRenderer.vue.d.ts +4 -0
  11. package/dist/runtime/app/components/islands/MarkdownIslandBody.d.vue.ts +10 -0
  12. package/dist/runtime/app/components/islands/MarkdownIslandBody.vue +80 -0
  13. package/dist/runtime/app/components/islands/MarkdownIslandBody.vue.d.ts +10 -0
  14. package/dist/runtime/app/components/islands/MarkdownIslandClient.d.vue.ts +9 -0
  15. package/dist/runtime/app/components/islands/MarkdownIslandClient.vue +20 -0
  16. package/dist/runtime/app/components/islands/MarkdownIslandClient.vue.d.ts +9 -0
  17. package/dist/runtime/app/components/islands/MarkdownIslandLink.d.vue.ts +26 -0
  18. package/dist/runtime/app/components/islands/MarkdownIslandLink.vue +23 -0
  19. package/dist/runtime/app/components/islands/MarkdownIslandLink.vue.d.ts +26 -0
  20. package/dist/runtime/app/components/islands/MarkdownIslandOutlet.d.vue.ts +9 -0
  21. package/dist/runtime/app/components/islands/MarkdownIslandOutlet.vue +13 -0
  22. package/dist/runtime/app/components/islands/MarkdownIslandOutlet.vue.d.ts +9 -0
  23. package/dist/runtime/app/components/renderer/MarkdownAnchor.vue +1 -0
  24. package/dist/runtime/app/components/renderer/MarkdownButton.d.vue.ts +1 -1
  25. package/dist/runtime/app/components/renderer/MarkdownButton.vue.d.ts +1 -1
  26. package/dist/runtime/app/components/renderer/MarkdownItemList.vue +1 -0
  27. package/dist/runtime/app/utils/component-manifest.d.ts +2 -4
  28. package/dist/runtime/app/utils/component-manifest.js +2 -2
  29. package/dist/runtime/server/utils/component-metadata-handler.d.ts +3 -0
  30. package/dist/runtime/server/utils/metadata.js +2 -0
  31. package/dist/runtime/shared/types.d.ts +4 -4
  32. package/dist/runtime/types/markdown-renderer.d.ts +3 -2
  33. package/dist/schema/editor-component-schema.d.ts +18 -7
  34. package/dist/schema/editor-component-schema.js +22 -3
  35. package/package.json +1 -1
package/README.md CHANGED
@@ -59,22 +59,100 @@ Import the module stylesheet in the consuming application's main CSS file after
59
59
  </template>
60
60
  ```
61
61
 
62
- | Prop | Type | Default | Description |
63
- | -------------- | ---------------- | ----------- | ----------------------------------------------- |
64
- | `value` | `string` | `undefined` | Markdown or MDC source. |
65
- | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
66
- | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
62
+ | Prop | Type | Default | Description |
63
+ | -------------- | ---------------- | ----------- | --------------------------------------------------------------- |
64
+ | `value` | `string` | `undefined` | Markdown or MDC source. |
65
+ | `plugins` | `ComarkPlugin[]` | `undefined` | Additional initialized Comark plugins. |
66
+ | `componentSet` | `string` | `undefined` | Optional configured custom-component allowlist. |
67
+ | `server` | `boolean` | `false` | Render static HTML inside a host `.server.vue` component. |
68
+ | `hydrate` | `string[]` | `undefined` | Registered block MDC component names to hydrate in server mode. |
69
+
70
+ ### Static Markdown and MDC in a server island
71
+
72
+ Enable Nuxt component islands and use `server` inside a host-owned `.server.vue` component with a
73
+ single root element. Use `componentIslands: true` for static HTML. To hydrate selected MDC blocks
74
+ with Nuxt's Vite builder, use `selectiveClient: "deep"`, as in this example with
75
+ `app/components/renderer/MarkdownCounter.vue`.
76
+ [Nuxt server components](https://nuxt.com/docs/4.x/guide/concepts/server-components)
77
+
78
+ ```ts
79
+ // nuxt.config.ts
80
+ export default defineNuxtConfig({
81
+ modules: ["@onderwijsin/nuxt-markdown-renderer"],
82
+ experimental: { componentIslands: { selectiveClient: "deep" } },
83
+ markdownRenderer: { componentSets: { article: ["MarkdownCounter", "MarkdownCallout"] } }
84
+ });
85
+ ```
86
+
87
+ ```vue
88
+ <!-- app/components/ArticleBody.server.vue -->
89
+ <script setup lang="ts">
90
+ import plugins from "~/markdown/plugins";
91
+
92
+ const { documentKey } = defineProps<{ documentKey: string }>();
93
+ const body = await useRequestFetch()<string>(
94
+ `/api/articles/${encodeURIComponent(documentKey)}/body`
95
+ );
96
+ </script>
97
+
98
+ <template>
99
+ <article>
100
+ <MarkdownRenderer
101
+ server
102
+ :value="body"
103
+ component-set="article"
104
+ :plugins="plugins"
105
+ :hydrate="['MarkdownCounter']"
106
+ />
107
+ </article>
108
+ </template>
109
+ ```
110
+
111
+ ```vue
112
+ <!-- app/pages/articles/[documentKey].vue -->
113
+ <script setup lang="ts">
114
+ const route = useRoute();
115
+ const documentKey = computed(() => String(route.params.documentKey));
116
+ </script>
117
+
118
+ <template>
119
+ <ArticleBody :document-key="documentKey" />
120
+ </template>
121
+ ```
122
+
123
+ Implement the example endpoint in the host app and return the document as Markdown text. The
124
+ `~/markdown/plugins` file default-exports the host's initialized Comark plugins. Omit the import and
125
+ `:plugins` binding to use the built-in plugins. Pass only a short public key to the host island
126
+ because Nuxt puts its props in the GET URL. Load the Markdown and initialize plugins, including
127
+ syntax highlighting, inside the island.
128
+
129
+ `hydrate` applies to registered MDC components allowed by the current set. Use selected components
130
+ as top-level blocks within the document. A component used inline or inside another block stays
131
+ static for that document. The renderer preserves default and named slots as server-rendered HTML.
132
+ Plain Markdown links remain anchors. Nuxt's island link navigation handles internal route links.
133
+
134
+ For private documents, authorize each request in the host loader or endpoint. Island requests bypass
135
+ page middleware. The renderer sends `Cache-Control: private, no-store` on the island response. Set
136
+ the same header on the enclosing page and data source, and disable shared caching and prerendering
137
+ for these routes, including `/__nuxt_island/**`. Reload the app when the viewer changes to discard
138
+ cached island HTML in that browser session.
139
+
140
+ Omit `server` to use the reactive renderer, including browser-side plugin execution.
141
+
142
+ ### Built-in MDC components
67
143
 
68
144
  The built-in MDC nodes are:
69
145
 
70
- | Markdown node | Vue implementation | Editor label | Behavior |
71
- | ----------------- | ------------------------- | ------------ | -------------------------------------------- |
72
- | `ItemList` | `MarkdownItemList` | Item list | Stacked page cards with optional dividers. |
73
- | `MarkdownAnchor` | `MarkdownAnchor` | Anchor | Invisible block target for fragment links. |
74
- | `MarkdownButton` | `MarkdownButton` | Button | Inline Nuxt UI button or link. |
75
- | `MarkdownCallout` | `MarkdownCallout` | Callout | Block Nuxt UI alert with editable content. |
76
- | `Reference` | `MarkdownReference` | — | Directus item reference; excluded from menu. |
77
- | `RelatedItemList` | `MarkdownRelatedItemList` | — | CMS selections rendered as mapped item rows. |
146
+ | Markdown node | Vue implementation | Editor label | Behavior |
147
+ | ------------------ | ------------------------- | ------------ | -------------------------------------------- |
148
+ | `MarkdownAnchor` | `MarkdownAnchor` | Anchor | Invisible block target for fragment links. |
149
+ | `MarkdownButton` | `MarkdownButton` | Button | Inline Nuxt UI button or link. |
150
+ | `MarkdownCallout` | `MarkdownCallout` | Callout | Block Nuxt UI alert with editable content. |
151
+ | `MarkdownItemList` | `MarkdownItemList` | Item list | Stacked page cards with optional dividers. |
152
+ | `Reference` | `MarkdownReference` | — | Directus item reference; excluded from menu. |
153
+ | `RelatedItemList` | `MarkdownRelatedItemList` | — | CMS selections rendered as mapped item rows. |
154
+
155
+ The CMS insert menu shows descriptions for Anchor, Button, Callout, and Item list.
78
156
 
79
157
  The built-in button's icon editor metadata uses the `lucide` collection by default. To offer other
80
158
  icon collections in component metadata, override the relevant renderer component and define its own
@@ -112,21 +190,21 @@ CSS after the module stylesheet:
112
190
 
113
191
  ### Item lists
114
192
 
115
- The `ItemList` node is rendered by `MarkdownItemList`, wrapping Nuxt UI's `UPageList` and ghost
116
- `UPageCard` components. It accepts a required `items` array and an optional boolean `divide` prop
117
- (default `false`). It exposes no content slots. All item fields are optional:
193
+ The `MarkdownItemList` component wraps Nuxt UI's `UPageList` and ghost `UPageCard` components. It
194
+ accepts a required `items` array and an optional boolean `divide` prop (default `false`). It exposes
195
+ no content slots. All item fields are optional:
118
196
 
119
197
  | Field | Type | Behavior |
120
198
  | ------------- | --------- | ------------------------------------------------------------------ |
121
- | `image` | `string` | Image URL, displayed instead of the icon when supplied. |
122
- | `title` | `string` | Item heading. |
123
- | `description` | `string` | Supporting text. |
199
+ | `title` | `string` | Title of the list item. |
200
+ | `description` | `string` | Supporting text below the title. |
124
201
  | `to` | `string` | Internal path or full URL. Omit to render an unlinked item. |
125
202
  | `external` | `boolean` | Opens `to` as an external link in a new tab. Ignored without `to`. |
203
+ | `image` | `string` | Leading image URL. Takes precedence over the icon. |
126
204
  | `icon` | `string` | Iconify icon name, used when no image is supplied. |
127
205
 
128
206
  ```mdc
129
- ::ItemList
207
+ ::MarkdownItemList
130
208
  ---
131
209
  divide: true
132
210
  items:
@@ -142,19 +220,22 @@ items:
142
220
  ::
143
221
  ```
144
222
 
145
- Include `ItemList` in any component set used to render it. Editor metadata provides image, URL, and
146
- Lucide icon controls for the nested fields. Conditional field visibility is not supported by the
147
- current metadata contract: `icon` and `external` remain visible in the editor; rendering gives
148
- images precedence and ignores `external` when `to` is empty.
223
+ Include `MarkdownItemList` in any component set used to render it. The CMS shows item fields in the
224
+ order above, with Image directly above Icon. Editor metadata provides image, URL, and Lucide icon
225
+ controls for the nested fields. The editor keeps `icon` and `external` visible. When rendered, an
226
+ image takes precedence over the icon, and `external` applies only when `to` is set.
227
+
228
+ When upgrading from v0.3.0, rename stored `::ItemList` blocks to `::MarkdownItemList` and update any
229
+ `ItemList` entries in `componentSets` and editor integrations to `MarkdownItemList`.
149
230
 
150
231
  ### Related item lists
151
232
 
152
233
  The `RelatedItemList` node is rendered by `MarkdownRelatedItemList`, reusing `MarkdownItemList` to
153
234
  render CMS-selected content in its original order. Its only prop is the required `items` array; it
154
- has no slots or additional display props. Like `MarkdownReference` → `Reference`, the Vue names are
155
- prefixed while persisted Markdown keeps the `ItemList` and `RelatedItemList` node names. Component
156
- sets use those persisted node names. Each selection has a required `collection: string` and
157
- `item: string | number`, plus optional `label: string` and `data: Record<string, unknown>`.
235
+ has no slots or additional display props. Like `MarkdownReference` → `Reference`,
236
+ `MarkdownRelatedItemList` keeps its CMS-owned node name `RelatedItemList`. Each selection has a
237
+ required `collection: string` and `item: string | number`, plus optional `label: string` and
238
+ `data: Record<string, unknown>`.
158
239
 
159
240
  ```mdc
160
241
  ::RelatedItemList
@@ -315,7 +396,7 @@ defineEditorComponentSchema({
315
396
  description: "A prominent page introduction.",
316
397
  type: "block",
317
398
  properties: {
318
- actionTo: { input: "url" },
399
+ actionTo: { label: "Call to action", input: "url" },
319
400
  image: { properties: { src: { input: "image" } } },
320
401
  actions: {
321
402
  items: {
@@ -366,19 +447,20 @@ For the module's built-in components, metadata inference reads the packaged type
366
447
  preserves JSDoc, defaults, slots, nested prop structure, and macro tags in installed applications as
367
448
  well as the module playground.
368
449
 
369
- | Field | Purpose |
370
- | ------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
371
- | `label` | Human-facing label, distinct from the Markdown node name. |
372
- | `description` | Help text shown while choosing a component. |
373
- | `type` | Required insertion behavior: `"block"` or `"inline"`. |
374
- | `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
375
- | `properties.<name>.values` | Explicit choices, particularly for imported union types. |
376
- | `properties.<name>.input` | `"image"`/`{ type: "image" }`, `"url"`/`{ type: "url" }`, or `{ type: "icon", collections: [...] }` for a string prop. |
377
- | `properties.<name>.properties` | Overrides for fields of an inferred object prop. |
378
- | `properties.<name>.items` | Overrides for the inferred item of an array prop. |
379
- | `properties.<name>.deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
380
- | `properties.<name>.type` | Explicit `string`, `number`, `boolean`, `object`, or `array` editor type. |
381
- | `properties.<name>.description/default/required` | Overrides the corresponding inferred metadata. |
450
+ | Field | Purpose |
451
+ | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
452
+ | `label` | Human-facing label, distinct from the Markdown node name. |
453
+ | `description` | Help text shown while choosing a component. |
454
+ | `type` | Required insertion behavior: `"block"` or `"inline"`. |
455
+ | `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
456
+ | `properties.<name>.label` | Optional display label for the prop in the editor. |
457
+ | `properties.<name>.values` | Explicit choices, particularly for imported union types. |
458
+ | `properties.<name>.input` | `"image"`, `"video"`, or `"url"` as shorthand or in an object such as `{ type: "video" }`. Icon uses `{ type: "icon", collections: [...] }`. |
459
+ | `properties.<name>.properties` | Overrides for fields of an inferred object prop. |
460
+ | `properties.<name>.items` | Overrides for the inferred item of an array prop. |
461
+ | `properties.<name>.deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
462
+ | `properties.<name>.type` | Explicit `string`, `number`, `boolean`, `object`, or `array` editor type. |
463
+ | `properties.<name>.description/default/required` | Overrides the corresponding inferred metadata. |
382
464
 
383
465
  The macro translates `input` and `deprecated` to the standard tags consumed by the Directus
384
466
  extension. Special inputs use a `specialInputType` tag; icon collections appear as
@@ -387,12 +469,13 @@ no options. Only fields declared by the input's Zod config schema are accepted a
387
469
  tag's `config` object. The lower-level `extendComponentMeta` macro remains available for metadata
388
470
  not covered by this convenience API. Invalid macro fields, including misspelled nested fields or
389
471
  unsupported input controls, produce a build warning with the failing property path; that component's
390
- editor overrides are ignored until the schema is corrected. The `image`, `url`, and `icon` inputs
391
- require an inferred string prop, including at nested paths. An incompatible inferred type causes the
392
- metadata endpoint to report the component and property path as a validation error.
472
+ editor overrides are ignored until the schema is corrected. The `image`, `video`, `url`, and `icon`
473
+ inputs require an inferred string prop, including at nested paths. An incompatible inferred type
474
+ causes the metadata endpoint to report the component and property path as a validation error.
393
475
 
394
476
  Use `properties` at the top level of `defineEditorComponentSchema` and for nested object fields. The
395
- generated metadata and Directus endpoint response continue to expose component fields as `props`.
477
+ metadata endpoint returns the fields under `props`, keyed by their Vue names. Each field carries an
478
+ optional `label` when one is supplied.
396
479
 
397
480
  ### Component sets
398
481
 
@@ -3,6 +3,7 @@ import { defineEditorComponentSchema } from "../../utils/define-editor-component
3
3
 
4
4
  defineEditorComponentSchema({
5
5
  label: "Anchor",
6
+ description: "Add a link target for jumping to this spot on the page.",
6
7
  type: "block"
7
8
  });
8
9
 
@@ -4,6 +4,7 @@ import type { ItemListItem } from "../../../shared/types";
4
4
 
5
5
  defineEditorComponentSchema({
6
6
  label: "Item list",
7
+ description: "Display a vertical list of cards with optional images, icons, and links.",
7
8
  type: "block",
8
9
  properties: {
9
10
  items: {
@@ -12,9 +12,7 @@ export interface RelatedItem {
12
12
 
13
13
  /** Display fields shared by the item-list components. */
14
14
  export interface ItemListItem {
15
- /** Image URL; takes precedence over the icon. */
16
- image?: string;
17
- /** Item title. */
15
+ /** title of the list item */
18
16
  title?: string;
19
17
  /** Supporting text below the title. */
20
18
  description?: string;
@@ -22,7 +20,9 @@ export interface ItemListItem {
22
20
  to?: string;
23
21
  /** Whether to open the destination as an external link in a new tab. */
24
22
  external?: boolean;
25
- /** Iconify icon name, displayed when no image is provided. */
23
+ /** Image that is leading the list item. */
24
+ image?: string;
25
+ /** Icon that is displayed when no image is provided. */
26
26
  icon?: string;
27
27
  }
28
28
 
@@ -19,7 +19,7 @@ const description = z.string().optional();
19
19
  const defaultValue = z.unknown().optional();
20
20
  /** Whether the editor requires a prop or nested property. */
21
21
  const required = z.boolean().optional();
22
- /** Human-readable component label supplied by the macro. */
22
+ /** Human-readable label supplied by the macro. */
23
23
  const label = z.string();
24
24
 
25
25
  /**
@@ -57,11 +57,19 @@ const urlInput = defineSpecialInput({
57
57
  propertyType: "string",
58
58
  config: z.strictObject({})
59
59
  });
60
+
61
+ const mediaInputConfig = z.strictObject({});
60
62
  /** Image editor control, with optional empty configuration. */
61
63
  const imageInput = defineSpecialInput({
62
64
  inputType: "image",
63
65
  propertyType: "string",
64
- config: z.strictObject({})
66
+ config: mediaInputConfig
67
+ });
68
+ /** Video editor control, with the same configuration as the image control. */
69
+ const videoInput = defineSpecialInput({
70
+ inputType: "video",
71
+ propertyType: "string",
72
+ config: mediaInputConfig
65
73
  });
66
74
  /** Icon editor control, requiring at least one Iconify collection. */
67
75
  const iconInput = defineSpecialInput({
@@ -77,11 +85,17 @@ const iconInput = defineSpecialInput({
77
85
  export const specialInputs = z.discriminatedUnion("inputType", [
78
86
  urlInput.endpoint,
79
87
  imageInput.endpoint,
88
+ videoInput.endpoint,
80
89
  iconInput.endpoint
81
90
  ]);
82
91
 
83
92
  /** Accepted macro input names, derived from the special-input definitions. */
84
- export const SpecialInputNameSchema = z.union([urlInput.name, imageInput.name, iconInput.name]);
93
+ export const SpecialInputNameSchema = z.union([
94
+ urlInput.name,
95
+ imageInput.name,
96
+ videoInput.name,
97
+ iconInput.name
98
+ ]);
85
99
 
86
100
  /**
87
101
  * Macro syntax for controls. Every control accepts an object form; controls without required
@@ -90,8 +104,14 @@ export const SpecialInputNameSchema = z.union([urlInput.name, imageInput.name, i
90
104
  export const SpecialInputMacroSchema = z.union([
91
105
  urlInput.shorthand,
92
106
  imageInput.shorthand,
107
+ videoInput.shorthand,
93
108
  iconInput.shorthand,
94
- z.discriminatedUnion("type", [urlInput.macro, imageInput.macro, iconInput.macro])
109
+ z.discriminatedUnion("type", [
110
+ urlInput.macro,
111
+ imageInput.macro,
112
+ videoInput.macro,
113
+ iconInput.macro
114
+ ])
95
115
  ]);
96
116
 
97
117
  /** Tag name used by the endpoint to identify a validated special editor input. */
@@ -110,6 +130,7 @@ const deprecation = z.union([z.boolean(), z.object({ text: z.string() }), z.stri
110
130
 
111
131
  /** Non-recursive property overrides accepted by the authoring macro. */
112
132
  const inputFields = z.strictObject({
133
+ label: label.optional(),
113
134
  values: choices.optional(),
114
135
  input: SpecialInputMacroSchema.optional(),
115
136
  deprecated: deprecation.optional(),
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-markdown-renderer",
3
3
  "configKey": "markdownRenderer",
4
- "version": "0.3.0",
4
+ "version": "0.5.0",
5
5
  "compatibility": {
6
6
  "nuxt": "^4.0.0"
7
7
  },
package/dist/module.mjs CHANGED
@@ -6,12 +6,11 @@ import { isRecord, isString, fromEntries, toEntries } from '@onderwijsin/nuxt-mo
6
6
  import { z } from 'zod';
7
7
  import { EditorComponentInputSchema, EditorComponentEnrichmentSchema, SPECIAL_INPUT_TAG_NAME } from '../dist/schema/editor-component-schema.js';
8
8
 
9
- const version = "0.3.0";
9
+ const version = "0.5.0";
10
10
 
11
11
  function resolveRendererNodeName(filePath) {
12
12
  const fileName = basename(filePath, extname(filePath));
13
13
  if (fileName === "MarkdownReference") return "Reference";
14
- if (fileName === "MarkdownItemList") return "ItemList";
15
14
  if (fileName === "MarkdownRelatedItemList") return "RelatedItemList";
16
15
  return fileName;
17
16
  }
@@ -34,6 +33,7 @@ function generateRendererManifest(components, componentSets) {
34
33
  ).join(",\n");
35
34
  return `import { createRendererManifest } from "#markdown-renderer/manifest-factory";
36
35
 
36
+ /** @type {Record<string, () => Promise<{ default: import("vue").Component }>>} */
37
37
  const componentLoaders = {
38
38
  ${loaders}
39
39
  };
@@ -239,8 +239,11 @@ export default createComponentMetadataHandler(
239
239
  nuxt.options.alias["#markdown-renderer/reference-resolver"] = referenceResolver;
240
240
  nuxt.options.alias["#markdown-renderer/related-item-mapper"] = options.relatedItemListConfig?.mapItem ? await resolvePath(options.relatedItemListConfig.mapItem) : resolver.resolve(runtimeDir, "app", "utils", "map-related-item");
241
241
  nuxt.options.alias["#markdown-renderer/related-item-resolver"] = options.relatedItemListConfig?.linkResolver ? await resolvePath(options.relatedItemListConfig.linkResolver) : resolver.resolve(runtimeDir, "app", "utils", "resolve-related-item-path");
242
+ const islands = nuxt.options.experimental?.componentIslands;
243
+ const selectiveHydration = typeof islands === "object" && islands.selectiveClient === "deep";
242
244
  nuxt.options.appConfig.markdownRenderer = {
243
- videoBaseUrl: options.videoBaseUrl
245
+ videoBaseUrl: options.videoBaseUrl,
246
+ ...selectiveHydration && { selectiveHydration }
244
247
  };
245
248
  transpileRuntime(nuxt, runtimeDir);
246
249
  addImports({
@@ -251,6 +254,18 @@ export default createComponentMetadataHandler(
251
254
  name: "MarkdownRenderer",
252
255
  filePath: resolver.resolve(runtimeDir, "app", "components", "MarkdownRenderer.vue")
253
256
  });
257
+ if (selectiveHydration) {
258
+ addComponent({
259
+ name: "MarkdownIslandClient",
260
+ filePath: resolver.resolve(
261
+ runtimeDir,
262
+ "app",
263
+ "components",
264
+ "islands",
265
+ "MarkdownIslandClient.vue"
266
+ )
267
+ });
268
+ }
254
269
  addComponentsDir({
255
270
  path: builtInDirectory,
256
271
  pathPrefix: false,
@@ -6,6 +6,10 @@ type __VLS_Props = {
6
6
  componentSet?: string;
7
7
  /** Optional array of plugins to enhance the Markdown rendering. */
8
8
  plugins?: ComarkPlugin[];
9
+ /** Render Markdown statically inside a host-owned Nuxt server component. */
10
+ server?: boolean;
11
+ /** Registered block MDC components to hydrate in server mode. */
12
+ hydrate?: string[];
9
13
  };
10
14
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
15
  declare const _default: typeof __VLS_export;
@@ -1,13 +1,29 @@
1
1
  <script setup>
2
2
  import { computed } from "vue";
3
- import { useAppConfig } from "#app";
3
+ import { useAppConfig, useNuxtApp, useResponseHeader } from "#app";
4
4
  import { resolveRendererComponent } from "#markdown-renderer/manifest";
5
5
  const props = defineProps({
6
6
  value: { type: String, required: false },
7
7
  componentSet: { type: String, required: false },
8
- plugins: { type: Array, required: false }
8
+ plugins: { type: Array, required: false },
9
+ server: { type: Boolean, required: false },
10
+ hydrate: { type: Array, required: false }
9
11
  });
10
12
  const config = useAppConfig().markdownRenderer;
13
+ if (props.server) {
14
+ if (!import.meta.server || !useNuxtApp().ssrContext?.islandContext) {
15
+ throw new Error(
16
+ "MarkdownRenderer with server enabled must be used inside a Nuxt server component."
17
+ );
18
+ }
19
+ if (props.hydrate?.length && !config.selectiveHydration) {
20
+ throw new Error(
21
+ "MarkdownRenderer hydration requires componentIslands.selectiveClient: 'deep'."
22
+ );
23
+ }
24
+ useResponseHeader("Cache-Control").value = "private, no-store";
25
+ }
26
+ const islandBody = import.meta.server && props.server ? (await import("./islands/MarkdownIslandBody.vue")).default : void 0;
11
27
  const componentsManifest = computed(
12
28
  () => (name) => resolveRendererComponent(name, props.componentSet)
13
29
  );
@@ -23,7 +39,16 @@ const lazilyExtendedPlugins = computed(() => [
23
39
  </script>
24
40
 
25
41
  <template>
42
+ <component
43
+ :is="islandBody"
44
+ v-if="islandBody"
45
+ :value="value"
46
+ :component-set="componentSet"
47
+ :plugins="lazilyExtendedPlugins"
48
+ :hydrate="hydrate"
49
+ />
26
50
  <Markdown
51
+ v-else
27
52
  :value="value"
28
53
  :components-manifest="componentsManifest"
29
54
  :plugins="lazilyExtendedPlugins"
@@ -6,6 +6,10 @@ type __VLS_Props = {
6
6
  componentSet?: string;
7
7
  /** Optional array of plugins to enhance the Markdown rendering. */
8
8
  plugins?: ComarkPlugin[];
9
+ /** Render Markdown statically inside a host-owned Nuxt server component. */
10
+ server?: boolean;
11
+ /** Registered block MDC components to hydrate in server mode. */
12
+ hydrate?: string[];
9
13
  };
10
14
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
15
  declare const _default: typeof __VLS_export;
@@ -0,0 +1,10 @@
1
+ import { type ComarkPlugin } from "comark";
2
+ type __VLS_Props = {
3
+ value?: string;
4
+ componentSet?: string;
5
+ plugins: ComarkPlugin[];
6
+ hydrate?: string[];
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,80 @@
1
+ <script setup>
2
+ import { isArray, isString } from "@onderwijsin/nuxt-module-utils/shared";
3
+ import { parseMarkdown } from "comark";
4
+ import { pascalCase, visit } from "comark/utils";
5
+ import { rendererComponentNames, resolveRendererComponent } from "#markdown-renderer/manifest";
6
+ import { defineComponent, getCurrentInstance, h } from "vue";
7
+ import { ssrRenderVNode } from "vue/server-renderer";
8
+ import MarkdownIslandLink from "./MarkdownIslandLink.vue";
9
+ import MarkdownIslandOutlet from "./MarkdownIslandOutlet.vue";
10
+ const props = defineProps({
11
+ value: { type: String, required: false },
12
+ componentSet: { type: String, required: false },
13
+ plugins: { type: Array, required: true },
14
+ hydrate: { type: Array, required: false }
15
+ });
16
+ const document = await parseMarkdown((props.value ?? "").trim(), { plugins: props.plugins });
17
+ const components = { ProseA: MarkdownIslandLink };
18
+ const requested = /* @__PURE__ */ new Set();
19
+ const nested = /* @__PURE__ */ new Set();
20
+ const roots = new Set(document.nodes);
21
+ function isElement(node) {
22
+ return isArray(node) && node[0] !== null;
23
+ }
24
+ visit(document, isElement, (node) => {
25
+ if (!isElement(node)) return;
26
+ for (const tag of [node[0], node[1].as]) {
27
+ if (!isString(tag)) continue;
28
+ requested.add(tag);
29
+ if (!roots.has(node)) nested.add(pascalCase(tag));
30
+ }
31
+ });
32
+ await Promise.all(
33
+ [...requested].map(async (tag) => {
34
+ const name = pascalCase(tag);
35
+ if (!rendererComponentNames.includes(name)) return;
36
+ const resolved = await resolveRendererComponent(tag, props.componentSet);
37
+ if (!resolved) {
38
+ components[name] = (_, { attrs, slots }) => h(tag, attrs, slots.default?.());
39
+ return;
40
+ }
41
+ components[name] = props.hydrate?.includes(name) && !nested.has(name) ? createIslandWidget(tag) : resolved.default;
42
+ })
43
+ );
44
+ async function readSlotHtml(item) {
45
+ if (isString(item)) return item;
46
+ return (await Promise.all((await item).map(readSlotHtml))).join("");
47
+ }
48
+ function createIslandWidget(tag) {
49
+ const { componentSet } = props;
50
+ return defineComponent({
51
+ inheritAttrs: false,
52
+ setup(_, { attrs, slots }) {
53
+ const parent = getCurrentInstance();
54
+ if (!parent) throw new Error("Markdown island slots require a Vue component instance.");
55
+ return () => {
56
+ const renderedSlots = Promise.all(
57
+ Object.entries(slots).map(async ([name, slot]) => {
58
+ const buffer = [];
59
+ ssrRenderVNode(
60
+ (item) => buffer.push(item),
61
+ h("span", { style: "display:contents" }, slot?.()),
62
+ parent
63
+ );
64
+ return [name, (await Promise.all(buffer.map(readSlotHtml))).join("")];
65
+ })
66
+ );
67
+ const Widget = defineComponent(async () => {
68
+ const slotHtml = Object.fromEntries(await renderedSlots);
69
+ return () => h(MarkdownIslandOutlet, { tag, componentSet, attributes: attrs, slotHtml });
70
+ });
71
+ return h(Widget);
72
+ };
73
+ }
74
+ });
75
+ }
76
+ </script>
77
+
78
+ <template>
79
+ <MarkdownDocument :value="document" :components="components" />
80
+ </template>
@@ -0,0 +1,10 @@
1
+ import { type ComarkPlugin } from "comark";
2
+ type __VLS_Props = {
3
+ value?: string;
4
+ componentSet?: string;
5
+ plugins: ComarkPlugin[];
6
+ hydrate?: string[];
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,20 @@
1
+ <script setup>
2
+ import { createStaticVNode } from "vue";
3
+ import { resolveRendererComponent } from "#markdown-renderer/manifest";
4
+ defineOptions({ inheritAttrs: false });
5
+ const props = defineProps({
6
+ tag: { type: String, required: true },
7
+ componentSet: { type: String, required: false },
8
+ attributes: { type: Object, required: true },
9
+ slotHtml: { type: Object, required: true }
10
+ });
11
+ const component = (await resolveRendererComponent(props.tag, props.componentSet))?.default;
12
+ </script>
13
+
14
+ <template>
15
+ <component :is="component" v-if="component" v-bind="attributes">
16
+ <template v-for="(html, name) in slotHtml" #[name]>
17
+ <component :is="() => createStaticVNode(html, 1)" />
18
+ </template>
19
+ </component>
20
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fileoverview
3
+ *
4
+ * Renders styled prose anchors in an island. NuxtLink resolves internal paths and the
5
+ * `data-internal` marker lets Nuxt handle navigation for those anchors.
6
+ */
7
+ import { ProseA } from "#components";
8
+ type __VLS_Props = {
9
+ href?: string;
10
+ target?: InstanceType<typeof ProseA>["$props"]["target"];
11
+ };
12
+ declare var __VLS_14: {}, __VLS_23: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_14) => any;
15
+ } & {
16
+ default?: (props: typeof __VLS_23) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import { ProseA } from "#components";
3
+ import { computed } from "vue";
4
+ defineOptions({ inheritAttrs: false });
5
+ const props = defineProps({
6
+ href: { type: String, required: false },
7
+ target: { type: null, required: false }
8
+ });
9
+ const internal = computed(
10
+ () => !!props.href && props.href.startsWith("/") && !props.href.startsWith("//") && (!props.target || props.target === "_self")
11
+ );
12
+ </script>
13
+
14
+ <template>
15
+ <NuxtLink v-if="internal" :to="href" custom v-slot="{ href: resolvedHref }">
16
+ <ProseA v-bind="$attrs" :href="resolvedHref ?? void 0" :target="target" data-internal="">
17
+ <slot />
18
+ </ProseA>
19
+ </NuxtLink>
20
+ <ProseA v-else v-bind="$attrs" :href="href" :target="target">
21
+ <slot />
22
+ </ProseA>
23
+ </template>
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @fileoverview
3
+ *
4
+ * Renders styled prose anchors in an island. NuxtLink resolves internal paths and the
5
+ * `data-internal` marker lets Nuxt handle navigation for those anchors.
6
+ */
7
+ import { ProseA } from "#components";
8
+ type __VLS_Props = {
9
+ href?: string;
10
+ target?: InstanceType<typeof ProseA>["$props"]["target"];
11
+ };
12
+ declare var __VLS_14: {}, __VLS_23: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_14) => any;
15
+ } & {
16
+ default?: (props: typeof __VLS_23) => any;
17
+ };
18
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
20
+ declare const _default: typeof __VLS_export;
21
+ export default _default;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,13 @@
1
+ <script setup>
2
+ import MarkdownIslandClient from "./MarkdownIslandClient.vue";
3
+ defineProps({
4
+ tag: { type: String, required: true },
5
+ componentSet: { type: String, required: false },
6
+ attributes: { type: Object, required: true },
7
+ slotHtml: { type: Object, required: true }
8
+ });
9
+ </script>
10
+
11
+ <template>
12
+ <MarkdownIslandClient nuxt-client v-bind="$props" />
13
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ tag: string;
3
+ componentSet?: string;
4
+ attributes: Record<string, unknown>;
5
+ slotHtml: Record<string, string>;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -2,6 +2,7 @@
2
2
  import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
3
3
  defineEditorComponentSchema({
4
4
  label: "Anchor",
5
+ description: "Add a link target for jumping to this spot on the page.",
5
6
  type: "block"
6
7
  });
7
8
  defineProps({
@@ -20,7 +20,7 @@ type __VLS_Props = {
20
20
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
21
21
  size: "xs" | "sm" | "md" | "lg" | "xl";
22
22
  color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
23
- variant: "link" | "ghost" | "solid" | "outline" | "soft" | "subtle";
23
+ variant: "link" | "solid" | "outline" | "soft" | "subtle" | "ghost";
24
24
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
25
  declare const _default: typeof __VLS_export;
26
26
  export default _default;
@@ -20,7 +20,7 @@ type __VLS_Props = {
20
20
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
21
21
  size: "xs" | "sm" | "md" | "lg" | "xl";
22
22
  color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
23
- variant: "link" | "ghost" | "solid" | "outline" | "soft" | "subtle";
23
+ variant: "link" | "solid" | "outline" | "soft" | "subtle" | "ghost";
24
24
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
25
25
  declare const _default: typeof __VLS_export;
26
26
  export default _default;
@@ -2,6 +2,7 @@
2
2
  import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
3
3
  defineEditorComponentSchema({
4
4
  label: "Item list",
5
+ description: "Display a vertical list of cards with optional images, icons, and links.",
5
6
  type: "block",
6
7
  properties: {
7
8
  items: {
@@ -1,13 +1,11 @@
1
- type ComponentLoader = () => Promise<unknown>;
2
1
  /**
3
2
  * Creates the runtime resolver around build-time generated lazy component imports.
4
3
  * @param componentLoaders Lazy imports keyed by renderer component name.
5
4
  * @param componentSets Configured component allowlists.
6
5
  * @returns Runtime manifest values consumed by `MarkdownRenderer` and metadata generation.
7
6
  */
8
- export declare function createRendererManifest(componentLoaders: Record<string, ComponentLoader>, componentSets: Record<string, string[]>): {
7
+ export declare function createRendererManifest<Module>(componentLoaders: Record<string, () => Promise<Module>>, componentSets: Record<string, string[]>): {
9
8
  componentSets: Record<string, string[]>;
10
9
  rendererComponentNames: string[];
11
- resolveRendererComponent(name: string, componentSet?: string): Promise<unknown> | null;
10
+ resolveRendererComponent(name: string, componentSet?: string): Promise<Module> | null;
12
11
  };
13
- export {};
@@ -7,11 +7,11 @@ export function createRendererManifest(componentLoaders, componentSets) {
7
7
  rendererComponentNames: Object.keys(componentLoaders),
8
8
  resolveRendererComponent(name, componentSet) {
9
9
  const normalizedName = resolveComponentName(name);
10
- const allowedComponents = componentSet ? componentSets[componentSet] : void 0;
10
+ const allowedComponents = componentSet && Object.hasOwn(componentSets, componentSet) ? componentSets[componentSet] : void 0;
11
11
  if (normalizedName !== "Reference" && normalizedName !== "RelatedItemList" && componentSet && (!allowedComponents || !allowedComponents.includes(normalizedName))) {
12
12
  return null;
13
13
  }
14
- return componentLoaders[normalizedName]?.() ?? null;
14
+ return Object.hasOwn(componentLoaders, normalizedName) ? componentLoaders[normalizedName]?.() ?? null : null;
15
15
  }
16
16
  };
17
17
  }
@@ -15,6 +15,7 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
15
15
  description?: string | undefined;
16
16
  values?: string[] | undefined;
17
17
  default?: unknown;
18
+ label?: string | undefined;
18
19
  required?: boolean | undefined;
19
20
  tags?: {
20
21
  name: string;
@@ -28,6 +29,7 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
28
29
  description?: string | undefined;
29
30
  values?: string[] | undefined;
30
31
  default?: unknown;
32
+ label?: string | undefined;
31
33
  required?: boolean | undefined;
32
34
  tags?: {
33
35
  name: string;
@@ -41,6 +43,7 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
41
43
  description?: string | undefined;
42
44
  values?: string[] | undefined;
43
45
  default?: unknown;
46
+ label?: string | undefined;
44
47
  required?: boolean | undefined;
45
48
  tags?: {
46
49
  name: string;
@@ -99,6 +99,7 @@ function transformProperty(value, custom, fallbackName, path) {
99
99
  if (!isRecord(value)) return void 0;
100
100
  const name = isString(value.name) ? value.name : fallbackName;
101
101
  if (!name) return void 0;
102
+ const label = custom?.label;
102
103
  const description = custom?.description ?? value.description;
103
104
  const values = custom?.values ?? resolveSchemaValues(value.schema);
104
105
  const inferredType = resolveEditorType(value.type);
@@ -121,6 +122,7 @@ function transformProperty(value, custom, fallbackName, path) {
121
122
  const required = custom?.required === true || custom?.required !== false && value.required === true;
122
123
  return {
123
124
  name,
125
+ ...isDefined(label) ? { label } : {},
124
126
  type,
125
127
  ...structure?.properties ? { properties: structure.properties } : {},
126
128
  ...structure?.items ? { items: structure.items } : {},
@@ -11,9 +11,7 @@ export interface RelatedItem {
11
11
  }
12
12
  /** Display fields shared by the item-list components. */
13
13
  export interface ItemListItem {
14
- /** Image URL; takes precedence over the icon. */
15
- image?: string;
16
- /** Item title. */
14
+ /** title of the list item */
17
15
  title?: string;
18
16
  /** Supporting text below the title. */
19
17
  description?: string;
@@ -21,7 +19,9 @@ export interface ItemListItem {
21
19
  to?: string;
22
20
  /** Whether to open the destination as an external link in a new tab. */
23
21
  external?: boolean;
24
- /** Iconify icon name, displayed when no image is provided. */
22
+ /** Image that is leading the list item. */
23
+ image?: string;
24
+ /** Icon that is displayed when no image is provided. */
25
25
  icon?: string;
26
26
  }
27
27
  /** Maps a CMS selection to display fields; the title defaults to the source label. */
@@ -1,18 +1,19 @@
1
1
  declare module "#markdown-renderer/manifest" {
2
- import type { ComponentManifest } from "comark";
2
+ import type { Component } from "vue";
3
3
 
4
4
  export const componentSets: Record<string, string[]>;
5
5
  export const rendererComponentNames: string[];
6
6
  export const resolveRendererComponent: (
7
7
  name: string,
8
8
  componentSet?: string
9
- ) => ReturnType<ComponentManifest>;
9
+ ) => Promise<{ default: Component }> | null;
10
10
  }
11
11
 
12
12
  declare module "nuxt/schema" {
13
13
  interface AppConfig {
14
14
  markdownRenderer: {
15
15
  videoBaseUrl?: string;
16
+ selectiveHydration?: boolean;
16
17
  };
17
18
  }
18
19
  }
@@ -11,6 +11,10 @@ export declare const specialInputs: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
11
  inputType: z.ZodLiteral<"image">;
12
12
  propertyType: z.ZodLiteral<"string">;
13
13
  config: z.ZodObject<{}, z.core.$strip> | z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ inputType: z.ZodLiteral<"video">;
16
+ propertyType: z.ZodLiteral<"string">;
17
+ config: z.ZodObject<{}, z.core.$strip> | z.ZodOptional<z.ZodObject<{}, z.core.$strip>>;
14
18
  }, z.core.$strip>, z.ZodObject<{
15
19
  inputType: z.ZodLiteral<"icon">;
16
20
  propertyType: z.ZodLiteral<"string">;
@@ -21,15 +25,17 @@ export declare const specialInputs: z.ZodDiscriminatedUnion<[z.ZodObject<{
21
25
  }, z.core.$strip>>;
22
26
  }, z.core.$strip>], "inputType">;
23
27
  /** Accepted macro input names, derived from the special-input definitions. */
24
- export declare const SpecialInputNameSchema: z.ZodUnion<readonly [z.ZodLiteral<"url">, z.ZodLiteral<"image">, z.ZodLiteral<"icon">]>;
28
+ export declare const SpecialInputNameSchema: z.ZodUnion<readonly [z.ZodLiteral<"url">, z.ZodLiteral<"image">, z.ZodLiteral<"video">, z.ZodLiteral<"icon">]>;
25
29
  /**
26
30
  * Macro syntax for controls. Every control accepts an object form; controls without required
27
31
  * configuration also accept their name as shorthand.
28
32
  */
29
- export declare const SpecialInputMacroSchema: z.ZodUnion<readonly [z.ZodCustom<"url", "url">, z.ZodCustom<"image", "image">, z.ZodCustom<never, never>, z.ZodDiscriminatedUnion<[z.ZodObject<{
33
+ export declare const SpecialInputMacroSchema: z.ZodUnion<readonly [z.ZodCustom<"url", "url">, z.ZodCustom<"image", "image">, z.ZodCustom<"video", "video">, z.ZodCustom<never, never>, z.ZodDiscriminatedUnion<[z.ZodObject<{
30
34
  type: z.ZodLiteral<"url">;
31
35
  }, z.core.$strict>, z.ZodObject<{
32
36
  type: z.ZodLiteral<"image">;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ type: z.ZodLiteral<"video">;
33
39
  }, z.core.$strict>, z.ZodObject<{
34
40
  type: z.ZodLiteral<"icon">;
35
41
  collections: z.ZodArray<z.ZodString>;
@@ -44,11 +50,14 @@ export declare const EditorTagSchema: z.ZodObject<{
44
50
  }, z.core.$strip>;
45
51
  /** Non-recursive property overrides accepted by the authoring macro. */
46
52
  declare const inputFields: z.ZodObject<{
53
+ label: z.ZodOptional<z.ZodString>;
47
54
  values: z.ZodOptional<z.ZodArray<z.ZodString>>;
48
- input: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<"url", "url">, z.ZodCustom<"image", "image">, z.ZodCustom<never, never>, z.ZodDiscriminatedUnion<[z.ZodObject<{
55
+ input: z.ZodOptional<z.ZodUnion<readonly [z.ZodCustom<"url", "url">, z.ZodCustom<"image", "image">, z.ZodCustom<"video", "video">, z.ZodCustom<never, never>, z.ZodDiscriminatedUnion<[z.ZodObject<{
49
56
  type: z.ZodLiteral<"url">;
50
57
  }, z.core.$strict>, z.ZodObject<{
51
58
  type: z.ZodLiteral<"image">;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ type: z.ZodLiteral<"video">;
52
61
  }, z.core.$strict>, z.ZodObject<{
53
62
  type: z.ZodLiteral<"icon">;
54
63
  collections: z.ZodArray<z.ZodString>;
@@ -103,6 +112,7 @@ declare const enrichmentFields: z.ZodObject<{
103
112
  array: "array";
104
113
  }>>;
105
114
  values: z.ZodOptional<z.ZodArray<z.ZodString>>;
115
+ label: z.ZodOptional<z.ZodString>;
106
116
  description: z.ZodOptional<z.ZodString>;
107
117
  required: z.ZodOptional<z.ZodBoolean>;
108
118
  }, z.core.$strip>;
@@ -125,8 +135,8 @@ export declare const EditorComponentEnrichmentSchema: z.ZodObject<{
125
135
  text: z.ZodOptional<z.ZodString>;
126
136
  config: z.ZodOptional<z.ZodUnknown>;
127
137
  }, z.core.$strip>>>;
128
- description: z.ZodOptional<z.ZodString>;
129
138
  label: z.ZodString;
139
+ description: z.ZodOptional<z.ZodString>;
130
140
  }, z.core.$strip>;
131
141
  /** Partial namespaced enrichment allowed for direct `extendComponentMeta` usage. */
132
142
  export declare const EditorComponentPartialEnrichmentSchema: z.ZodObject<{
@@ -140,8 +150,8 @@ export declare const EditorComponentPartialEnrichmentSchema: z.ZodObject<{
140
150
  text: z.ZodOptional<z.ZodString>;
141
151
  config: z.ZodOptional<z.ZodUnknown>;
142
152
  }, z.core.$strip>>>>;
143
- description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
144
153
  label: z.ZodOptional<z.ZodString>;
154
+ description: z.ZodOptional<z.ZodOptional<z.ZodString>>;
145
155
  }, z.core.$strip>;
146
156
  /** Editor property fields after inference supplies a required name and type. */
147
157
  declare const outputFields: z.ZodObject<{
@@ -155,6 +165,7 @@ declare const outputFields: z.ZodObject<{
155
165
  }>;
156
166
  default: z.ZodOptional<z.ZodUnknown>;
157
167
  values: z.ZodOptional<z.ZodArray<z.ZodString>>;
168
+ label: z.ZodOptional<z.ZodString>;
158
169
  description: z.ZodOptional<z.ZodString>;
159
170
  required: z.ZodOptional<z.ZodBoolean>;
160
171
  tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -175,8 +186,8 @@ export declare const EditorComponentOutputSchema: z.ZodObject<{
175
186
  name: z.ZodString;
176
187
  props: z.ZodRecord<z.ZodString, z.ZodType<RecursiveOutput, unknown, z.core.$ZodTypeInternals<RecursiveOutput, unknown>>>;
177
188
  slots: z.ZodArray<z.ZodString>;
178
- description: z.ZodOptional<z.ZodString>;
179
189
  label: z.ZodString;
190
+ description: z.ZodOptional<z.ZodString>;
180
191
  tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
181
192
  name: z.ZodString;
182
193
  text: z.ZodOptional<z.ZodString>;
@@ -192,8 +203,8 @@ export declare const EditorComponentResponseSchema: z.ZodArray<z.ZodObject<{
192
203
  name: z.ZodString;
193
204
  props: z.ZodRecord<z.ZodString, z.ZodType<RecursiveOutput, unknown, z.core.$ZodTypeInternals<RecursiveOutput, unknown>>>;
194
205
  slots: z.ZodArray<z.ZodString>;
195
- description: z.ZodOptional<z.ZodString>;
196
206
  label: z.ZodString;
207
+ description: z.ZodOptional<z.ZodString>;
197
208
  tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
198
209
  name: z.ZodString;
199
210
  text: z.ZodOptional<z.ZodString>;
@@ -29,10 +29,16 @@ const urlInput = defineSpecialInput({
29
29
  propertyType: "string",
30
30
  config: z.strictObject({})
31
31
  });
32
+ const mediaInputConfig = z.strictObject({});
32
33
  const imageInput = defineSpecialInput({
33
34
  inputType: "image",
34
35
  propertyType: "string",
35
- config: z.strictObject({})
36
+ config: mediaInputConfig
37
+ });
38
+ const videoInput = defineSpecialInput({
39
+ inputType: "video",
40
+ propertyType: "string",
41
+ config: mediaInputConfig
36
42
  });
37
43
  const iconInput = defineSpecialInput({
38
44
  inputType: "icon",
@@ -42,14 +48,26 @@ const iconInput = defineSpecialInput({
42
48
  export const specialInputs = z.discriminatedUnion("inputType", [
43
49
  urlInput.endpoint,
44
50
  imageInput.endpoint,
51
+ videoInput.endpoint,
45
52
  iconInput.endpoint
46
53
  ]);
47
- export const SpecialInputNameSchema = z.union([urlInput.name, imageInput.name, iconInput.name]);
54
+ export const SpecialInputNameSchema = z.union([
55
+ urlInput.name,
56
+ imageInput.name,
57
+ videoInput.name,
58
+ iconInput.name
59
+ ]);
48
60
  export const SpecialInputMacroSchema = z.union([
49
61
  urlInput.shorthand,
50
62
  imageInput.shorthand,
63
+ videoInput.shorthand,
51
64
  iconInput.shorthand,
52
- z.discriminatedUnion("type", [urlInput.macro, imageInput.macro, iconInput.macro])
65
+ z.discriminatedUnion("type", [
66
+ urlInput.macro,
67
+ imageInput.macro,
68
+ videoInput.macro,
69
+ iconInput.macro
70
+ ])
53
71
  ]);
54
72
  export const SPECIAL_INPUT_TAG_NAME = "specialInputType";
55
73
  export const EditorTagSchema = z.object({
@@ -60,6 +78,7 @@ export const EditorTagSchema = z.object({
60
78
  const tags = z.array(EditorTagSchema).optional();
61
79
  const deprecation = z.union([z.boolean(), z.object({ text: z.string() }), z.string().min(1)]);
62
80
  const inputFields = z.strictObject({
81
+ label: label.optional(),
63
82
  values: choices.optional(),
64
83
  input: SpecialInputMacroSchema.optional(),
65
84
  deprecated: deprecation.optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onderwijsin/nuxt-markdown-renderer",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Nuxt module for rendering Markdown content.",
5
5
  "homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
6
6
  "bugs": {