@onderwijsin/nuxt-markdown-renderer 0.2.3 → 0.4.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.
- package/README.md +217 -45
- package/dist/metadata/runtime/app/components/renderer/MarkdownAnchor.vue +18 -0
- package/dist/metadata/runtime/app/components/renderer/MarkdownItemList.vue +53 -0
- package/dist/metadata/runtime/app/components/renderer/MarkdownRelatedItemList.vue +22 -0
- package/dist/metadata/runtime/shared/types.ts +41 -0
- package/dist/metadata/schema/editor-component-schema.ts +25 -4
- package/dist/module.d.mts +14 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +15 -4
- package/dist/runtime/app/components/renderer/MarkdownAnchor.d.vue.ts +7 -0
- package/dist/runtime/app/components/renderer/MarkdownAnchor.vue +15 -0
- package/dist/runtime/app/components/renderer/MarkdownAnchor.vue.d.ts +7 -0
- package/dist/runtime/app/components/renderer/MarkdownButton.d.vue.ts +2 -2
- package/dist/runtime/app/components/renderer/MarkdownButton.vue.d.ts +2 -2
- package/dist/runtime/app/components/renderer/MarkdownCallout.d.vue.ts +1 -1
- package/dist/runtime/app/components/renderer/MarkdownCallout.vue.d.ts +1 -1
- package/dist/runtime/app/components/renderer/MarkdownItemList.d.vue.ts +12 -0
- package/dist/runtime/app/components/renderer/MarkdownItemList.vue +45 -0
- package/dist/runtime/app/components/renderer/MarkdownItemList.vue.d.ts +12 -0
- package/dist/runtime/app/components/renderer/MarkdownRelatedItemList.d.vue.ts +8 -0
- package/dist/runtime/app/components/renderer/MarkdownRelatedItemList.vue +16 -0
- package/dist/runtime/app/components/renderer/MarkdownRelatedItemList.vue.d.ts +8 -0
- package/dist/runtime/app/utils/component-manifest.js +1 -1
- package/dist/runtime/app/utils/map-related-item.d.ts +7 -0
- package/dist/runtime/app/utils/map-related-item.js +2 -0
- package/dist/runtime/app/utils/map-related-items.d.ts +11 -0
- package/dist/runtime/app/utils/map-related-items.js +7 -0
- package/dist/runtime/app/utils/resolve-related-item-path.d.ts +7 -0
- package/dist/runtime/app/utils/resolve-related-item-path.js +2 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/server/utils/component-metadata-handler.d.ts +6 -3
- package/dist/runtime/server/utils/metadata.d.ts +2 -2
- package/dist/runtime/server/utils/metadata.js +3 -1
- package/dist/runtime/shared/types.d.ts +30 -0
- package/dist/schema/editor-component-schema.d.ts +18 -7
- package/dist/schema/editor-component-schema.js +22 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@ components, and component metadata for the Directus Markdown editor.
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
8
|
- Renders Markdown and MDC through the global `MarkdownRenderer` component.
|
|
9
|
-
- Includes `
|
|
9
|
+
- Includes `MarkdownItemList`, `MarkdownRelatedItemList`, `MarkdownAnchor`, `MarkdownButton`,
|
|
10
|
+
`MarkdownCallout`, and the persisted `Reference` node.
|
|
10
11
|
- Discovers application renderer components through Nuxt's component registry.
|
|
11
12
|
- Lazily imports custom components and optionally restricts them with named component sets.
|
|
12
13
|
- Exposes Directus-compatible component metadata, including CORS preflight handling.
|
|
@@ -66,11 +67,16 @@ Import the module stylesheet in the consuming application's main CSS file after
|
|
|
66
67
|
|
|
67
68
|
The built-in MDC nodes are:
|
|
68
69
|
|
|
69
|
-
| Markdown node
|
|
70
|
-
|
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
70
|
+
| Markdown node | Vue implementation | Editor label | Behavior |
|
|
71
|
+
| ------------------ | ------------------------- | ------------ | -------------------------------------------- |
|
|
72
|
+
| `MarkdownAnchor` | `MarkdownAnchor` | Anchor | Invisible block target for fragment links. |
|
|
73
|
+
| `MarkdownButton` | `MarkdownButton` | Button | Inline Nuxt UI button or link. |
|
|
74
|
+
| `MarkdownCallout` | `MarkdownCallout` | Callout | Block Nuxt UI alert with editable content. |
|
|
75
|
+
| `MarkdownItemList` | `MarkdownItemList` | Item list | Stacked page cards with optional dividers. |
|
|
76
|
+
| `Reference` | `MarkdownReference` | — | Directus item reference; excluded from menu. |
|
|
77
|
+
| `RelatedItemList` | `MarkdownRelatedItemList` | — | CMS selections rendered as mapped item rows. |
|
|
78
|
+
|
|
79
|
+
The CMS insert menu shows descriptions for Anchor, Button, Callout, and Item list.
|
|
74
80
|
|
|
75
81
|
The built-in button's icon editor metadata uses the `lucide` collection by default. To offer other
|
|
76
82
|
icon collections in component metadata, override the relevant renderer component and define its own
|
|
@@ -83,6 +89,154 @@ For example:
|
|
|
83
89
|
:MarkdownButton{label="documentation" to="/docs" variant="soft"}. ::
|
|
84
90
|
```
|
|
85
91
|
|
|
92
|
+
### Fragment anchors
|
|
93
|
+
|
|
94
|
+
Insert an invisible block anchor with a required string `id` and no slots:
|
|
95
|
+
|
|
96
|
+
```mdc
|
|
97
|
+
::MarkdownAnchor{id="existing-fragment"}
|
|
98
|
+
::
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This renders `<span id="existing-fragment" class="markdown-anchor"></span>`. Link to it with
|
|
102
|
+
`[Jump to section](#existing-fragment)`. Include `MarkdownAnchor` in any component set used to
|
|
103
|
+
render it.
|
|
104
|
+
|
|
105
|
+
The module stylesheet uses `display: block` and `scroll-margin-top: 100px` to give the empty span a
|
|
106
|
+
−100px scroll offset without adding visible content or layout space. Override the offset in your own
|
|
107
|
+
CSS after the module stylesheet:
|
|
108
|
+
|
|
109
|
+
```css
|
|
110
|
+
.markdown-anchor {
|
|
111
|
+
scroll-margin-top: 64px;
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Item lists
|
|
116
|
+
|
|
117
|
+
The `MarkdownItemList` component wraps Nuxt UI's `UPageList` and ghost `UPageCard` components. It
|
|
118
|
+
accepts a required `items` array and an optional boolean `divide` prop (default `false`). It exposes
|
|
119
|
+
no content slots. All item fields are optional:
|
|
120
|
+
|
|
121
|
+
| Field | Type | Behavior |
|
|
122
|
+
| ------------- | --------- | ------------------------------------------------------------------ |
|
|
123
|
+
| `title` | `string` | Title of the list item. |
|
|
124
|
+
| `description` | `string` | Supporting text below the title. |
|
|
125
|
+
| `to` | `string` | Internal path or full URL. Omit to render an unlinked item. |
|
|
126
|
+
| `external` | `boolean` | Opens `to` as an external link in a new tab. Ignored without `to`. |
|
|
127
|
+
| `image` | `string` | Leading image URL. Takes precedence over the icon. |
|
|
128
|
+
| `icon` | `string` | Iconify icon name, used when no image is supplied. |
|
|
129
|
+
|
|
130
|
+
```mdc
|
|
131
|
+
::MarkdownItemList
|
|
132
|
+
---
|
|
133
|
+
divide: true
|
|
134
|
+
items:
|
|
135
|
+
- title: Our services
|
|
136
|
+
description: Explore how we can help.
|
|
137
|
+
image: /images/services.jpg
|
|
138
|
+
to: /services
|
|
139
|
+
- title: Nuxt UI
|
|
140
|
+
icon: i-lucide-external-link
|
|
141
|
+
to: https://ui.nuxt.com
|
|
142
|
+
external: true
|
|
143
|
+
---
|
|
144
|
+
::
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Include `MarkdownItemList` in any component set used to render it. The CMS shows item fields in the
|
|
148
|
+
order above, with Image directly above Icon. Editor metadata provides image, URL, and Lucide icon
|
|
149
|
+
controls for the nested fields. The editor keeps `icon` and `external` visible. When rendered, an
|
|
150
|
+
image takes precedence over the icon, and `external` applies only when `to` is set.
|
|
151
|
+
|
|
152
|
+
When upgrading from v0.3.0, rename stored `::ItemList` blocks to `::MarkdownItemList` and update any
|
|
153
|
+
`ItemList` entries in `componentSets` and editor integrations to `MarkdownItemList`.
|
|
154
|
+
|
|
155
|
+
### Related item lists
|
|
156
|
+
|
|
157
|
+
The `RelatedItemList` node is rendered by `MarkdownRelatedItemList`, reusing `MarkdownItemList` to
|
|
158
|
+
render CMS-selected content in its original order. Its only prop is the required `items` array; it
|
|
159
|
+
has no slots or additional display props. Like `MarkdownReference` → `Reference`,
|
|
160
|
+
`MarkdownRelatedItemList` keeps its CMS-owned node name `RelatedItemList`. Each selection has a
|
|
161
|
+
required `collection: string` and `item: string | number`, plus optional `label: string` and
|
|
162
|
+
`data: Record<string, unknown>`.
|
|
163
|
+
|
|
164
|
+
```mdc
|
|
165
|
+
::RelatedItemList
|
|
166
|
+
---
|
|
167
|
+
items:
|
|
168
|
+
- collection: articles
|
|
169
|
+
item: article-7
|
|
170
|
+
label: Becoming a teacher
|
|
171
|
+
data:
|
|
172
|
+
slug: becoming-a-teacher
|
|
173
|
+
summary: Explore the routes into teaching.
|
|
174
|
+
image: image-uuid
|
|
175
|
+
- collection: programs
|
|
176
|
+
item: 42
|
|
177
|
+
label: Teaching traineeship
|
|
178
|
+
data:
|
|
179
|
+
slug: teaching-traineeship
|
|
180
|
+
duration: 24
|
|
181
|
+
---
|
|
182
|
+
::
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Set `markdownRenderer.relatedItemListConfig.mapItem` and `.linkResolver` to Nuxt-resolvable callback
|
|
186
|
+
file paths. Without configuration, rows display their source labels and remain unlinked; the
|
|
187
|
+
renderer does not guess snapshot fields, image URLs, or application routes.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
// app/utils/mapRelatedItem.ts
|
|
191
|
+
import type { MapRelatedItem } from "@onderwijsin/nuxt-markdown-renderer/runtime";
|
|
192
|
+
|
|
193
|
+
const mapRelatedItem: MapRelatedItem = (item) => {
|
|
194
|
+
const { summary, duration, image } = item.data ?? {};
|
|
195
|
+
return {
|
|
196
|
+
description:
|
|
197
|
+
typeof summary === "string"
|
|
198
|
+
? summary
|
|
199
|
+
: typeof duration === "number"
|
|
200
|
+
? `${duration} months`
|
|
201
|
+
: undefined,
|
|
202
|
+
image:
|
|
203
|
+
typeof image === "string"
|
|
204
|
+
? `https://cms.example.com/assets/${encodeURIComponent(image)}`
|
|
205
|
+
: undefined
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export default mapRelatedItem;
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
// app/utils/resolveRelatedItemPath.ts
|
|
214
|
+
import type { ResolveRelatedItemPath } from "@onderwijsin/nuxt-markdown-renderer/runtime";
|
|
215
|
+
|
|
216
|
+
const resolveRelatedItemPath: ResolveRelatedItemPath = (item) => {
|
|
217
|
+
const slug = item.data?.slug;
|
|
218
|
+
if (typeof slug !== "string") return undefined;
|
|
219
|
+
if (item.collection === "articles") return `/articles/${encodeURIComponent(slug)}`;
|
|
220
|
+
if (item.collection === "programs") return `/programs/${encodeURIComponent(slug)}`;
|
|
221
|
+
return undefined;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export default resolveRelatedItemPath;
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Both callbacks are optional, synchronous, and receive the full selection. `mapItem` returns any
|
|
228
|
+
`ItemListItem` fields except `to`; the source label remains the title unless overridden.
|
|
229
|
+
`linkResolver` returns the `to` string, or `undefined` to keep a row unlinked. The `/runtime`
|
|
230
|
+
entrypoint exports `RelatedItem`, `ItemListItem`, `MapRelatedItem`, and `ResolveRelatedItemPath`
|
|
231
|
+
types. Callback code is bundled for SSR and client rendering; do not put secrets in it.
|
|
232
|
+
|
|
233
|
+
Like `Reference`, this node resolves independently of component sets and is excluded from generic
|
|
234
|
+
editor metadata because the CMS owns its selection UI. It accepts no additional attributes,
|
|
235
|
+
including `divide`, and uses the default undivided layout. Like `Reference`, related items use a
|
|
236
|
+
TypeScript contract without runtime prop validation. Consumers own validation at their CMS/content
|
|
237
|
+
ingestion boundary and conversion of collection-specific snapshot fields. Snapshots are rendered as
|
|
238
|
+
provided, without fetching data.
|
|
239
|
+
|
|
86
240
|
## Configuration
|
|
87
241
|
|
|
88
242
|
```ts
|
|
@@ -95,22 +249,37 @@ export default defineNuxtConfig({
|
|
|
95
249
|
article: ["MarkdownButton", "MarkdownCallout", "MarkdownHero"],
|
|
96
250
|
landing: ["MarkdownButton", "MarkdownHero"]
|
|
97
251
|
},
|
|
98
|
-
|
|
252
|
+
referenceConfig: { linkResolver: "~/utils/resolveReferencePath" },
|
|
253
|
+
relatedItemListConfig: {
|
|
254
|
+
mapItem: "~/utils/mapRelatedItem",
|
|
255
|
+
linkResolver: "~/utils/resolveRelatedItemPath"
|
|
256
|
+
},
|
|
99
257
|
videoBaseUrl: "https://media.example.com/assets/",
|
|
100
258
|
corsOrigin: "https://directus.example.com"
|
|
101
259
|
}
|
|
102
260
|
});
|
|
103
261
|
```
|
|
104
262
|
|
|
105
|
-
| Option
|
|
106
|
-
|
|
|
107
|
-
| `enabled`
|
|
108
|
-
| `scopeComponentMeta`
|
|
109
|
-
| `componentsDir`
|
|
110
|
-
| `componentSets`
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
263
|
+
| Option | Type | Default | Description |
|
|
264
|
+
| ----------------------- | --------------------------------------------- | ------------ | ----------------------------------------------------------------- |
|
|
265
|
+
| `enabled` | `boolean` | `true` | Enables component, manifest, and metadata endpoint registration. |
|
|
266
|
+
| `scopeComponentMeta` | `boolean` | `true` | Limits global component metadata extraction to renderer sources. |
|
|
267
|
+
| `componentsDir` | `string` | `"renderer"` | Directory below `app/components/` containing renderer components. |
|
|
268
|
+
| `componentSets` | `Record<string, string[]>` | `{}` | Named allowlists used by rendering and metadata endpoints. |
|
|
269
|
+
| `referenceConfig` | `{ linkResolver?: string }` | unset | Reference callback file paths. |
|
|
270
|
+
| `relatedItemListConfig` | `{ mapItem?: string; linkResolver?: string }` | unset | Related-list callback file paths. |
|
|
271
|
+
| `videoBaseUrl` | `string` | unset | Absolute base URL for relative video sources. |
|
|
272
|
+
| `corsOrigin` | `string \| string[]` | `"*"` | Origins allowed to call the metadata endpoint from a browser. |
|
|
273
|
+
|
|
274
|
+
Both configuration objects and their callback paths are optional. Each path resolves through Nuxt
|
|
275
|
+
aliases and extensions and points to a default-exported function. A missing reference link resolver
|
|
276
|
+
keeps references as plain text; a missing related-item mapper keeps source labels; a missing
|
|
277
|
+
related-item link resolver keeps rows unlinked. Callback code runs during SSR and in the browser.
|
|
278
|
+
|
|
279
|
+
**Breaking migration:** replace `resolveReferencePath: "~/utils/resolveReferencePath"` with
|
|
280
|
+
`referenceConfig: { linkResolver: "~/utils/resolveReferencePath" }`. The resolver file, its function
|
|
281
|
+
signature, and stored `Reference` nodes remain unchanged. The old option is rejected rather than
|
|
282
|
+
silently ignored. This breaking configuration change is intentionally released as a minor.
|
|
114
283
|
|
|
115
284
|
A single `corsOrigin` string is accepted and normalized to an allowlist. Use `"null"` only when a
|
|
116
285
|
sandboxed or local client intentionally sends an opaque origin.
|
|
@@ -151,7 +320,7 @@ defineEditorComponentSchema({
|
|
|
151
320
|
description: "A prominent page introduction.",
|
|
152
321
|
type: "block",
|
|
153
322
|
properties: {
|
|
154
|
-
actionTo: { input: "url" },
|
|
323
|
+
actionTo: { label: "Call to action", input: "url" },
|
|
155
324
|
image: { properties: { src: { input: "image" } } },
|
|
156
325
|
actions: {
|
|
157
326
|
items: {
|
|
@@ -202,19 +371,20 @@ For the module's built-in components, metadata inference reads the packaged type
|
|
|
202
371
|
preserves JSDoc, defaults, slots, nested prop structure, and macro tags in installed applications as
|
|
203
372
|
well as the module playground.
|
|
204
373
|
|
|
205
|
-
| Field | Purpose
|
|
206
|
-
| ------------------------------------------------ |
|
|
207
|
-
| `label` | Human-facing label, distinct from the Markdown node name.
|
|
208
|
-
| `description` | Help text shown while choosing a component.
|
|
209
|
-
| `type` | Required insertion behavior: `"block"` or `"inline"`.
|
|
210
|
-
| `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`.
|
|
211
|
-
| `properties.<name>.
|
|
212
|
-
| `properties.<name>.
|
|
213
|
-
| `properties.<name>.
|
|
214
|
-
| `properties.<name>.
|
|
215
|
-
| `properties.<name>.
|
|
216
|
-
| `properties.<name>.
|
|
217
|
-
| `properties.<name>.
|
|
374
|
+
| Field | Purpose |
|
|
375
|
+
| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
376
|
+
| `label` | Human-facing label, distinct from the Markdown node name. |
|
|
377
|
+
| `description` | Help text shown while choosing a component. |
|
|
378
|
+
| `type` | Required insertion behavior: `"block"` or `"inline"`. |
|
|
379
|
+
| `deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
|
|
380
|
+
| `properties.<name>.label` | Optional display label for the prop in the editor. |
|
|
381
|
+
| `properties.<name>.values` | Explicit choices, particularly for imported union types. |
|
|
382
|
+
| `properties.<name>.input` | `"image"`, `"video"`, or `"url"` as shorthand or in an object such as `{ type: "video" }`. Icon uses `{ type: "icon", collections: [...] }`. |
|
|
383
|
+
| `properties.<name>.properties` | Overrides for fields of an inferred object prop. |
|
|
384
|
+
| `properties.<name>.items` | Overrides for the inferred item of an array prop. |
|
|
385
|
+
| `properties.<name>.deprecated` | `true`, a non-empty guidance string, or `{ text: string }`. |
|
|
386
|
+
| `properties.<name>.type` | Explicit `string`, `number`, `boolean`, `object`, or `array` editor type. |
|
|
387
|
+
| `properties.<name>.description/default/required` | Overrides the corresponding inferred metadata. |
|
|
218
388
|
|
|
219
389
|
The macro translates `input` and `deprecated` to the standard tags consumed by the Directus
|
|
220
390
|
extension. Special inputs use a `specialInputType` tag; icon collections appear as
|
|
@@ -223,12 +393,13 @@ no options. Only fields declared by the input's Zod config schema are accepted a
|
|
|
223
393
|
tag's `config` object. The lower-level `extendComponentMeta` macro remains available for metadata
|
|
224
394
|
not covered by this convenience API. Invalid macro fields, including misspelled nested fields or
|
|
225
395
|
unsupported input controls, produce a build warning with the failing property path; that component's
|
|
226
|
-
editor overrides are ignored until the schema is corrected. The `image`, `url`, and `icon`
|
|
227
|
-
require an inferred string prop, including at nested paths. An incompatible inferred type
|
|
228
|
-
metadata endpoint to report the component and property path as a validation error.
|
|
396
|
+
editor overrides are ignored until the schema is corrected. The `image`, `video`, `url`, and `icon`
|
|
397
|
+
inputs require an inferred string prop, including at nested paths. An incompatible inferred type
|
|
398
|
+
causes the metadata endpoint to report the component and property path as a validation error.
|
|
229
399
|
|
|
230
400
|
Use `properties` at the top level of `defineEditorComponentSchema` and for nested object fields. The
|
|
231
|
-
|
|
401
|
+
metadata endpoint returns the fields under `props`, keyed by their Vue names. Each field carries an
|
|
402
|
+
optional `label` when one is supplied.
|
|
232
403
|
|
|
233
404
|
### Component sets
|
|
234
405
|
|
|
@@ -237,8 +408,9 @@ Component-set values use the public Markdown node names. Passing `component-set=
|
|
|
237
408
|
URL returns only that set. An unknown set prevents custom component resolution and its metadata URL
|
|
238
409
|
returns HTTP 404.
|
|
239
410
|
|
|
240
|
-
The
|
|
241
|
-
unknown sets.
|
|
411
|
+
The CMS-owned `Reference` and `RelatedItemList` nodes always resolve regardless of the selected set,
|
|
412
|
+
including empty or unknown sets. They remain excluded from all metadata endpoints and need no set
|
|
413
|
+
entry.
|
|
242
414
|
|
|
243
415
|
Omit `component-set` to allow every discovered renderer component.
|
|
244
416
|
|
|
@@ -251,7 +423,7 @@ https://website.example.com/api/markdown-renderer/components/article
|
|
|
251
423
|
```
|
|
252
424
|
|
|
253
425
|
The endpoint returns a bare component array. Omit the final set name to return all discovered
|
|
254
|
-
components. `Reference`
|
|
426
|
+
components. `Reference` and `RelatedItemList` are omitted because the CMS owns those editor nodes.
|
|
255
427
|
Both `GET` and browser `OPTIONS` preflight requests are handled.
|
|
256
428
|
|
|
257
429
|
The endpoint is public and sends no authentication challenge. CORS controls which browser origins
|
|
@@ -296,14 +468,14 @@ auto-imports, templates, and routes are not registered.
|
|
|
296
468
|
|
|
297
469
|
## Troubleshooting
|
|
298
470
|
|
|
299
|
-
| Symptom | Check
|
|
300
|
-
| ------------------------------------ |
|
|
301
|
-
| Custom component renders as Markdown | Put it directly in `app/components/<componentsDir>/` and use its Nuxt name.
|
|
302
|
-
| Component is missing for one field | Include its public name in the selected `componentSets` entry.
|
|
303
|
-
| Metadata URL returns 404 | The requested component-set name is not configured.
|
|
304
|
-
| Directus reports a CORS failure | Add the exact Directus origin to `corsOrigin`, including scheme and port.
|
|
305
|
-
| Metadata omits a custom component | Ensure the SFC is discoverable and exposes parseable component metadata.
|
|
306
|
-
| Reference is not linked | Configure `
|
|
471
|
+
| Symptom | Check |
|
|
472
|
+
| ------------------------------------ | -------------------------------------------------------------------------------- |
|
|
473
|
+
| Custom component renders as Markdown | Put it directly in `app/components/<componentsDir>/` and use its Nuxt name. |
|
|
474
|
+
| Component is missing for one field | Include its public name in the selected `componentSets` entry. |
|
|
475
|
+
| Metadata URL returns 404 | The requested component-set name is not configured. |
|
|
476
|
+
| Directus reports a CORS failure | Add the exact Directus origin to `corsOrigin`, including scheme and port. |
|
|
477
|
+
| Metadata omits a custom component | Ensure the SFC is discoverable and exposes parseable component metadata. |
|
|
478
|
+
| Reference is not linked | Configure `referenceConfig.linkResolver` and return a route for that collection. |
|
|
307
479
|
|
|
308
480
|
## Development
|
|
309
481
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
|
|
3
|
+
|
|
4
|
+
defineEditorComponentSchema({
|
|
5
|
+
label: "Anchor",
|
|
6
|
+
description: "Add a link target for jumping to this spot on the page.",
|
|
7
|
+
type: "block"
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
defineProps<{
|
|
11
|
+
/** Fragment identifier targeted by anchor links. */
|
|
12
|
+
id: string;
|
|
13
|
+
}>();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<span :id="id" class="markdown-anchor" />
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
|
|
3
|
+
import type { ItemListItem } from "../../../shared/types";
|
|
4
|
+
|
|
5
|
+
defineEditorComponentSchema({
|
|
6
|
+
label: "Item list",
|
|
7
|
+
description: "Display a vertical list of cards with optional images, icons, and links.",
|
|
8
|
+
type: "block",
|
|
9
|
+
properties: {
|
|
10
|
+
items: {
|
|
11
|
+
items: {
|
|
12
|
+
properties: {
|
|
13
|
+
image: { input: "image" },
|
|
14
|
+
to: { input: "url" },
|
|
15
|
+
icon: { input: { type: "icon", collections: ["lucide"] } }
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
withDefaults(
|
|
23
|
+
defineProps<{
|
|
24
|
+
/** Whether to show dividers between items. */
|
|
25
|
+
divide?: boolean;
|
|
26
|
+
/** Items displayed as stacked page cards. */
|
|
27
|
+
items: ItemListItem[];
|
|
28
|
+
}>(),
|
|
29
|
+
{ divide: false }
|
|
30
|
+
);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<UPageList as="ul" :divide="divide">
|
|
35
|
+
<UPageCard
|
|
36
|
+
v-for="(item, index) in items"
|
|
37
|
+
:key="index"
|
|
38
|
+
as="li"
|
|
39
|
+
variant="ghost"
|
|
40
|
+
:title="item.title"
|
|
41
|
+
:description="item.description"
|
|
42
|
+
:to="item.to"
|
|
43
|
+
:external="!!item.to && item.external"
|
|
44
|
+
:target="item.to && item.external ? '_blank' : undefined"
|
|
45
|
+
:icon="item.image ? undefined : item.icon"
|
|
46
|
+
:ui="{ wrapper: 'flex-row items-center gap-4', leading: 'mb-0' }"
|
|
47
|
+
>
|
|
48
|
+
<template v-if="item.image" #leading>
|
|
49
|
+
<img :src="item.image" alt="" loading="lazy" class="size-12 rounded-md object-cover" />
|
|
50
|
+
</template>
|
|
51
|
+
</UPageCard>
|
|
52
|
+
</UPageList>
|
|
53
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
|
|
4
|
+
import mapItem from "#markdown-renderer/related-item-mapper";
|
|
5
|
+
import linkResolver from "#markdown-renderer/related-item-resolver";
|
|
6
|
+
import type { RelatedItem } from "../../../shared/types";
|
|
7
|
+
import { mapRelatedItems } from "../../utils/map-related-items";
|
|
8
|
+
import MarkdownItemList from "./MarkdownItemList.vue";
|
|
9
|
+
|
|
10
|
+
defineOptions({ inheritAttrs: false });
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
/** Ordered CMS selections with collection-specific source snapshots. */
|
|
14
|
+
items: RelatedItem[];
|
|
15
|
+
}>();
|
|
16
|
+
|
|
17
|
+
const mappedItems = computed(() => mapRelatedItems(props.items, { mapItem, linkResolver }));
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<MarkdownItemList :items="mappedItems" />
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** One persisted CMS selection, retaining string or numeric primary keys. */
|
|
2
|
+
export interface RelatedItem {
|
|
3
|
+
/** Source collection name. */
|
|
4
|
+
collection: string;
|
|
5
|
+
/** Source item primary key. */
|
|
6
|
+
item: string | number;
|
|
7
|
+
/** Source display label. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Collection-specific source snapshot supplied by the CMS. */
|
|
10
|
+
data?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Display fields shared by the item-list components. */
|
|
14
|
+
export interface ItemListItem {
|
|
15
|
+
/** title of the list item */
|
|
16
|
+
title?: string;
|
|
17
|
+
/** Supporting text below the title. */
|
|
18
|
+
description?: string;
|
|
19
|
+
/** Link destination, either an internal path or a full URL. */
|
|
20
|
+
to?: string;
|
|
21
|
+
/** Whether to open the destination as an external link in a new tab. */
|
|
22
|
+
external?: boolean;
|
|
23
|
+
/** Image that is leading the list item. */
|
|
24
|
+
image?: string;
|
|
25
|
+
/** Icon that is displayed when no image is provided. */
|
|
26
|
+
icon?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Maps a CMS selection to display fields; the title defaults to the source label. */
|
|
30
|
+
export type MapRelatedItem = (item: RelatedItem) => Omit<ItemListItem, "to">;
|
|
31
|
+
|
|
32
|
+
/** Resolves a CMS selection's destination, or leaves the row unlinked. */
|
|
33
|
+
export type ResolveRelatedItemPath = (item: RelatedItem) => string | undefined;
|
|
34
|
+
|
|
35
|
+
export type ResolveReferencePath = (
|
|
36
|
+
collection: string,
|
|
37
|
+
item: string,
|
|
38
|
+
label?: string,
|
|
39
|
+
text?: string,
|
|
40
|
+
data?: Record<string, unknown>
|
|
41
|
+
) => string | undefined;
|
|
@@ -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
|
|
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:
|
|
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([
|
|
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", [
|
|
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.d.mts
CHANGED
|
@@ -6,7 +6,13 @@ declare const _default: _nuxt_schema.NuxtModule<{
|
|
|
6
6
|
scopeComponentMeta?: boolean | undefined;
|
|
7
7
|
componentsDir?: string | undefined;
|
|
8
8
|
componentSets?: Record<string, string[]> | undefined;
|
|
9
|
-
|
|
9
|
+
referenceConfig?: {
|
|
10
|
+
linkResolver?: string | undefined;
|
|
11
|
+
} | undefined;
|
|
12
|
+
relatedItemListConfig?: {
|
|
13
|
+
mapItem?: string | undefined;
|
|
14
|
+
linkResolver?: string | undefined;
|
|
15
|
+
} | undefined;
|
|
10
16
|
videoBaseUrl?: string | undefined;
|
|
11
17
|
corsOrigin?: string | string[] | undefined;
|
|
12
18
|
}, {
|
|
@@ -14,7 +20,13 @@ declare const _default: _nuxt_schema.NuxtModule<{
|
|
|
14
20
|
scopeComponentMeta?: boolean | undefined;
|
|
15
21
|
componentsDir?: string | undefined;
|
|
16
22
|
componentSets?: Record<string, string[]> | undefined;
|
|
17
|
-
|
|
23
|
+
referenceConfig?: {
|
|
24
|
+
linkResolver?: string | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
relatedItemListConfig?: {
|
|
27
|
+
mapItem?: string | undefined;
|
|
28
|
+
linkResolver?: string | undefined;
|
|
29
|
+
} | undefined;
|
|
18
30
|
videoBaseUrl?: string | undefined;
|
|
19
31
|
corsOrigin?: string | string[] | undefined;
|
|
20
32
|
}, false>;
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,11 +6,13 @@ 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.
|
|
9
|
+
const version = "0.4.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 === "MarkdownRelatedItemList") return "RelatedItemList";
|
|
15
|
+
return fileName;
|
|
14
16
|
}
|
|
15
17
|
function selectRendererComponents(components, directories) {
|
|
16
18
|
const rendererDirectories = new Set(directories.map((directory) => resolve(directory)));
|
|
@@ -107,13 +109,20 @@ ${z.prettifyError(parsed.error)}`
|
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
const origin = z.string().trim().min(1);
|
|
112
|
+
const callbackPath = z.string().trim().min(1);
|
|
110
113
|
const markdownRendererOptionsSchema = z.strictObject({
|
|
111
114
|
enabled: enabled.default(true),
|
|
112
115
|
/** Scope the global component-meta parser to renderer sources; disable for application metadata. */
|
|
113
116
|
scopeComponentMeta: z.boolean().default(true),
|
|
114
117
|
componentsDir: z.string().trim().min(1).default("renderer"),
|
|
115
118
|
componentSets: z.record(z.string(), z.array(z.string().trim().min(1))).default({}),
|
|
116
|
-
|
|
119
|
+
/** Consumer-owned reference callbacks, resolved through Nuxt aliases and extensions. */
|
|
120
|
+
referenceConfig: z.strictObject({ linkResolver: callbackPath.optional() }).optional(),
|
|
121
|
+
/** Consumer-owned related-list callbacks, resolved through Nuxt aliases and extensions. */
|
|
122
|
+
relatedItemListConfig: z.strictObject({
|
|
123
|
+
mapItem: callbackPath.optional(),
|
|
124
|
+
linkResolver: callbackPath.optional()
|
|
125
|
+
}).optional(),
|
|
117
126
|
videoBaseUrl: z.url().optional(),
|
|
118
127
|
corsOrigin: z.union([
|
|
119
128
|
z.literal("*"),
|
|
@@ -218,7 +227,7 @@ export default createComponentMetadataHandler(
|
|
|
218
227
|
);
|
|
219
228
|
`
|
|
220
229
|
});
|
|
221
|
-
const referenceResolver = options.
|
|
230
|
+
const referenceResolver = options.referenceConfig?.linkResolver ? await resolvePath(options.referenceConfig.linkResolver) : resolver.resolve(runtimeDir, "app", "utils", "resolve-reference-path");
|
|
222
231
|
nuxt.options.alias["#markdown-renderer/manifest"] = manifest.dst;
|
|
223
232
|
nuxt.options.alias["#markdown-renderer/manifest-factory"] = resolver.resolve(
|
|
224
233
|
runtimeDir,
|
|
@@ -227,6 +236,8 @@ export default createComponentMetadataHandler(
|
|
|
227
236
|
"component-manifest"
|
|
228
237
|
);
|
|
229
238
|
nuxt.options.alias["#markdown-renderer/reference-resolver"] = referenceResolver;
|
|
239
|
+
nuxt.options.alias["#markdown-renderer/related-item-mapper"] = options.relatedItemListConfig?.mapItem ? await resolvePath(options.relatedItemListConfig.mapItem) : resolver.resolve(runtimeDir, "app", "utils", "map-related-item");
|
|
240
|
+
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");
|
|
230
241
|
nuxt.options.appConfig.markdownRenderer = {
|
|
231
242
|
videoBaseUrl: options.videoBaseUrl
|
|
232
243
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** Fragment identifier targeted by anchor links. */
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
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>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
|
|
3
|
+
defineEditorComponentSchema({
|
|
4
|
+
label: "Anchor",
|
|
5
|
+
description: "Add a link target for jumping to this spot on the page.",
|
|
6
|
+
type: "block"
|
|
7
|
+
});
|
|
8
|
+
defineProps({
|
|
9
|
+
id: { type: String, required: true }
|
|
10
|
+
});
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<span :id="id" class="markdown-anchor" />
|
|
15
|
+
</template>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** Fragment identifier targeted by anchor links. */
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
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>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
|
@@ -19,8 +19,8 @@ type __VLS_Props = {
|
|
|
19
19
|
};
|
|
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
|
-
color: "
|
|
23
|
-
variant: "solid" | "outline" | "soft" | "subtle" | "ghost"
|
|
22
|
+
color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
|
|
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;
|
|
@@ -19,8 +19,8 @@ type __VLS_Props = {
|
|
|
19
19
|
};
|
|
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
|
-
color: "
|
|
23
|
-
variant: "solid" | "outline" | "soft" | "subtle" | "ghost"
|
|
22
|
+
color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
|
|
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;
|
|
@@ -35,7 +35,7 @@ type __VLS_Slots = {} & {
|
|
|
35
35
|
description?: (props: typeof __VLS_9) => any;
|
|
36
36
|
};
|
|
37
37
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
38
|
-
color: "
|
|
38
|
+
color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
|
|
39
39
|
variant: "solid" | "outline" | "soft" | "subtle";
|
|
40
40
|
orientation: "horizontal" | "vertical";
|
|
41
41
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -35,7 +35,7 @@ type __VLS_Slots = {} & {
|
|
|
35
35
|
description?: (props: typeof __VLS_9) => any;
|
|
36
36
|
};
|
|
37
37
|
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
38
|
-
color: "
|
|
38
|
+
color: "success" | "error" | "primary" | "secondary" | "info" | "warning" | "neutral";
|
|
39
39
|
variant: "solid" | "outline" | "soft" | "subtle";
|
|
40
40
|
orientation: "horizontal" | "vertical";
|
|
41
41
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ItemListItem } from "../../../shared/types.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Whether to show dividers between items. */
|
|
4
|
+
divide?: boolean;
|
|
5
|
+
/** Items displayed as stacked page cards. */
|
|
6
|
+
items: ItemListItem[];
|
|
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<{}>, {
|
|
9
|
+
divide: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { defineEditorComponentSchema } from "../../utils/define-editor-component-schema";
|
|
3
|
+
defineEditorComponentSchema({
|
|
4
|
+
label: "Item list",
|
|
5
|
+
description: "Display a vertical list of cards with optional images, icons, and links.",
|
|
6
|
+
type: "block",
|
|
7
|
+
properties: {
|
|
8
|
+
items: {
|
|
9
|
+
items: {
|
|
10
|
+
properties: {
|
|
11
|
+
image: { input: "image" },
|
|
12
|
+
to: { input: "url" },
|
|
13
|
+
icon: { input: { type: "icon", collections: ["lucide"] } }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
defineProps({
|
|
20
|
+
divide: { type: Boolean, required: false, default: false },
|
|
21
|
+
items: { type: Array, required: true }
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<UPageList as="ul" :divide="divide">
|
|
27
|
+
<UPageCard
|
|
28
|
+
v-for="(item, index) in items"
|
|
29
|
+
:key="index"
|
|
30
|
+
as="li"
|
|
31
|
+
variant="ghost"
|
|
32
|
+
:title="item.title"
|
|
33
|
+
:description="item.description"
|
|
34
|
+
:to="item.to"
|
|
35
|
+
:external="!!item.to && item.external"
|
|
36
|
+
:target="item.to && item.external ? '_blank' : void 0"
|
|
37
|
+
:icon="item.image ? void 0 : item.icon"
|
|
38
|
+
:ui="{ wrapper: 'flex-row items-center gap-4', leading: 'mb-0' }"
|
|
39
|
+
>
|
|
40
|
+
<template v-if="item.image" #leading>
|
|
41
|
+
<img :src="item.image" alt="" loading="lazy" class="size-12 rounded-md object-cover" />
|
|
42
|
+
</template>
|
|
43
|
+
</UPageCard>
|
|
44
|
+
</UPageList>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ItemListItem } from "../../../shared/types.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Whether to show dividers between items. */
|
|
4
|
+
divide?: boolean;
|
|
5
|
+
/** Items displayed as stacked page cards. */
|
|
6
|
+
items: ItemListItem[];
|
|
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<{}>, {
|
|
9
|
+
divide: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RelatedItem } from "../../../shared/types.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Ordered CMS selections with collection-specific source snapshots. */
|
|
4
|
+
items: RelatedItem[];
|
|
5
|
+
};
|
|
6
|
+
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>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import mapItem from "#markdown-renderer/related-item-mapper";
|
|
4
|
+
import linkResolver from "#markdown-renderer/related-item-resolver";
|
|
5
|
+
import { mapRelatedItems } from "../../utils/map-related-items";
|
|
6
|
+
import MarkdownItemList from "./MarkdownItemList.vue";
|
|
7
|
+
defineOptions({ inheritAttrs: false });
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
items: { type: Array, required: true }
|
|
10
|
+
});
|
|
11
|
+
const mappedItems = computed(() => mapRelatedItems(props.items, { mapItem, linkResolver }));
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<MarkdownItemList :items="mappedItems" />
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RelatedItem } from "../../../shared/types.js";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Ordered CMS selections with collection-specific source snapshots. */
|
|
4
|
+
items: RelatedItem[];
|
|
5
|
+
};
|
|
6
|
+
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>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -8,7 +8,7 @@ export function createRendererManifest(componentLoaders, componentSets) {
|
|
|
8
8
|
resolveRendererComponent(name, componentSet) {
|
|
9
9
|
const normalizedName = resolveComponentName(name);
|
|
10
10
|
const allowedComponents = componentSet ? componentSets[componentSet] : void 0;
|
|
11
|
-
if (normalizedName !== "Reference" && componentSet && (!allowedComponents || !allowedComponents.includes(normalizedName))) {
|
|
11
|
+
if (normalizedName !== "Reference" && normalizedName !== "RelatedItemList" && componentSet && (!allowedComponents || !allowedComponents.includes(normalizedName))) {
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
return componentLoaders[normalizedName]?.() ?? null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ItemListItem, MapRelatedItem, RelatedItem, ResolveRelatedItemPath } from "../../shared/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Maps persisted selections to display rows without changing their order.
|
|
4
|
+
* @param items Persisted CMS selections.
|
|
5
|
+
* @param config Consumer-owned display mapping and link resolver.
|
|
6
|
+
* @returns Rows for the item-list renderer.
|
|
7
|
+
*/
|
|
8
|
+
export declare function mapRelatedItems(items: RelatedItem[], config: {
|
|
9
|
+
mapItem?: MapRelatedItem;
|
|
10
|
+
linkResolver?: ResolveRelatedItemPath;
|
|
11
|
+
}): ItemListItem[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolveRelatedItemPath } from "../../shared/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Leaves related rows unlinked until the consumer defines its route semantics.
|
|
4
|
+
* @returns No destination.
|
|
5
|
+
*/
|
|
6
|
+
declare const resolveRelatedItemPath: ResolveRelatedItemPath;
|
|
7
|
+
export default resolveRelatedItemPath;
|
package/dist/runtime/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@source "./app";@tailwindcss/typography;
|
|
1
|
+
@source "./app";@tailwindcss/typography;.markdown-anchor{display:block;scroll-margin-top:100px}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { ResolveReferencePath } from "./shared/types.js";
|
|
1
|
+
export type { ItemListItem, MapRelatedItem, RelatedItem, ResolveRelatedItemPath, ResolveReferencePath } from "./shared/types.js";
|
|
@@ -12,9 +12,10 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
|
|
|
12
12
|
props: Record<string, {
|
|
13
13
|
name: string;
|
|
14
14
|
type: "string" | "number" | "boolean" | "object" | "array";
|
|
15
|
+
description?: string | undefined;
|
|
15
16
|
values?: string[] | undefined;
|
|
16
17
|
default?: unknown;
|
|
17
|
-
|
|
18
|
+
label?: string | undefined;
|
|
18
19
|
required?: boolean | undefined;
|
|
19
20
|
tags?: {
|
|
20
21
|
name: string;
|
|
@@ -25,9 +26,10 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
|
|
|
25
26
|
properties?: Record<string, {
|
|
26
27
|
name: string;
|
|
27
28
|
type: "string" | "number" | "boolean" | "object" | "array";
|
|
29
|
+
description?: string | undefined;
|
|
28
30
|
values?: string[] | undefined;
|
|
29
31
|
default?: unknown;
|
|
30
|
-
|
|
32
|
+
label?: string | undefined;
|
|
31
33
|
required?: boolean | undefined;
|
|
32
34
|
tags?: {
|
|
33
35
|
name: string;
|
|
@@ -38,9 +40,10 @@ export declare function createComponentMetadataHandler(componentMeta: unknown, r
|
|
|
38
40
|
items?: {
|
|
39
41
|
name: string;
|
|
40
42
|
type: "string" | "number" | "boolean" | "object" | "array";
|
|
43
|
+
description?: string | undefined;
|
|
41
44
|
values?: string[] | undefined;
|
|
42
45
|
default?: unknown;
|
|
43
|
-
|
|
46
|
+
label?: string | undefined;
|
|
44
47
|
required?: boolean | undefined;
|
|
45
48
|
tags?: {
|
|
46
49
|
name: string;
|
|
@@ -9,8 +9,8 @@ export interface EditorComponentSource {
|
|
|
9
9
|
* Converts Nuxt component metadata to the Directus Markdown editor contract.
|
|
10
10
|
*
|
|
11
11
|
* The registry is an external/generated boundary, so every value is narrowed before use. Reserved
|
|
12
|
-
* `Reference`
|
|
13
|
-
* metadata are also omitted rather than returning an incomplete contract.
|
|
12
|
+
* `Reference` and `RelatedItemList` are omitted because the CMS owns those editor nodes.
|
|
13
|
+
* Components without parsed metadata are also omitted rather than returning an incomplete contract.
|
|
14
14
|
*
|
|
15
15
|
* The result is a bare array. The Directus extension accepts either this shape or a legacy
|
|
16
16
|
* `{ components: [...] }` wrapper and normalizes both; the array avoids an unnecessary envelope.
|
|
@@ -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 } : {},
|
|
@@ -141,7 +143,7 @@ function resolveCustomComponentMetadata(meta) {
|
|
|
141
143
|
export function createEditorComponentMetadata(registry, components) {
|
|
142
144
|
if (!isRecord(registry)) return [];
|
|
143
145
|
const output = components.flatMap(({ name, componentName }) => {
|
|
144
|
-
if (name === "Reference") return [];
|
|
146
|
+
if (name === "Reference" || name === "RelatedItemList") return [];
|
|
145
147
|
const component = registry[componentName];
|
|
146
148
|
if (!isRecord(component) || !isRecord(component.meta)) return [];
|
|
147
149
|
const custom = resolveCustomComponentMetadata(component.meta);
|
|
@@ -1 +1,31 @@
|
|
|
1
|
+
/** One persisted CMS selection, retaining string or numeric primary keys. */
|
|
2
|
+
export interface RelatedItem {
|
|
3
|
+
/** Source collection name. */
|
|
4
|
+
collection: string;
|
|
5
|
+
/** Source item primary key. */
|
|
6
|
+
item: string | number;
|
|
7
|
+
/** Source display label. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** Collection-specific source snapshot supplied by the CMS. */
|
|
10
|
+
data?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/** Display fields shared by the item-list components. */
|
|
13
|
+
export interface ItemListItem {
|
|
14
|
+
/** title of the list item */
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Supporting text below the title. */
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Link destination, either an internal path or a full URL. */
|
|
19
|
+
to?: string;
|
|
20
|
+
/** Whether to open the destination as an external link in a new tab. */
|
|
21
|
+
external?: boolean;
|
|
22
|
+
/** Image that is leading the list item. */
|
|
23
|
+
image?: string;
|
|
24
|
+
/** Icon that is displayed when no image is provided. */
|
|
25
|
+
icon?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Maps a CMS selection to display fields; the title defaults to the source label. */
|
|
28
|
+
export type MapRelatedItem = (item: RelatedItem) => Omit<ItemListItem, "to">;
|
|
29
|
+
/** Resolves a CMS selection's destination, or leaves the row unlinked. */
|
|
30
|
+
export type ResolveRelatedItemPath = (item: RelatedItem) => string | undefined;
|
|
1
31
|
export type ResolveReferencePath = (collection: string, item: string, label?: string, text?: string, data?: Record<string, unknown>) => string | undefined;
|
|
@@ -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:
|
|
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([
|
|
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", [
|
|
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
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Nuxt module for rendering Markdown content.",
|
|
5
5
|
"homepage": "https://github.com/onderwijsin/nuxt-modules#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"shiki": "4.4.3",
|
|
48
48
|
"ufo": "1.6.4",
|
|
49
49
|
"zod": "4.4.3",
|
|
50
|
-
"@onderwijsin/nuxt-module-utils": "^0.5.
|
|
50
|
+
"@onderwijsin/nuxt-module-utils": "^0.5.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@comark/nuxt": "0.7.0",
|