|
1 | 1 | import { defineCollection, defineContentConfig, z } from '@nuxt/content' |
| 2 | +import { asOgImageCollection } from 'nuxt-og-image/content' |
2 | 3 |
|
3 | 4 | export default defineContentConfig({ |
4 | 5 | collections: { |
5 | | - docs: defineCollection({ |
6 | | - type: 'page', |
7 | | - source: { |
8 | | - include: '**', |
9 | | - exclude: ['index.md'] |
10 | | - }, |
11 | | - schema: z.object({ |
12 | | - links: z.array(z.object({ |
13 | | - label: z.string(), |
14 | | - icon: z.string(), |
15 | | - to: z.string(), |
16 | | - target: z.string().optional(), |
17 | | - variant: z.enum(['link', 'solid', 'outline', 'soft', 'subtle', 'ghost']).optional(), |
18 | | - alt: z.string().optional() |
19 | | - })).optional(), |
20 | | - image: z.object({ src: z.string().nonempty().editor({ input: 'media' }) }), |
21 | | - authors: z.array( |
22 | | - z.object({ |
23 | | - name: z.string().nonempty(), |
24 | | - to: z.string().nonempty(), |
25 | | - avatar: z.object({ src: z.string().nonempty().editor({ input: 'media' }) }) |
26 | | - }) |
27 | | - ), |
28 | | - hide: z.boolean().optional(), |
29 | | - date: z.date(), |
30 | | - badge: z.object({ label: z.string().nonempty() }), |
31 | | - // Schema.org structured data - universal approach |
32 | | - schemaOrg: z.union([ |
33 | | - // ScholarlyArticle |
34 | | - z.object({ |
35 | | - type: z.literal('ScholarlyArticle'), |
36 | | - headline: z.string().optional(), |
37 | | - datePublished: z.string().optional(), |
38 | | - abstract: z.string().optional(), |
39 | | - image: z.string().optional(), |
40 | | - publisher: z.union([ |
41 | | - z.object({ |
42 | | - type: z.literal('Organization'), |
43 | | - name: z.string() |
44 | | - }), |
45 | | - z.string() |
46 | | - ]).optional(), |
47 | | - author: z.array(z.object({ |
48 | | - name: z.string(), |
49 | | - identifier: z.string().optional(), |
50 | | - type: z.literal('Person').optional(), |
51 | | - affiliation: z.string().optional(), |
52 | | - url: z.string().optional() |
53 | | - })).optional(), |
54 | | - keywords: z.array(z.string()).optional(), |
55 | | - mainEntityOfPage: z.string().optional(), |
56 | | - sameAs: z.string().optional(), |
57 | | - citation: z.object({ |
58 | | - type: z.string().optional(), |
59 | | - name: z.string().optional() |
60 | | - }).optional() |
61 | | - }), |
62 | | - // WebPage (default) |
63 | | - z.object({ |
64 | | - type: z.literal('WebPage'), |
65 | | - headline: z.string().optional(), |
66 | | - description: z.string().optional(), |
67 | | - image: z.string().optional(), |
68 | | - datePublished: z.string().optional(), |
69 | | - dateModified: z.string().optional() |
70 | | - }), |
71 | | - // BlogPosting |
72 | | - z.object({ |
73 | | - type: z.literal('BlogPosting'), |
74 | | - headline: z.string().optional(), |
75 | | - author: z.union([ |
76 | | - z.array(z.object({ |
77 | | - type: z.literal('Person').optional(), |
| 6 | + docs: defineCollection( |
| 7 | + asOgImageCollection({ |
| 8 | + type: 'page', |
| 9 | + source: { |
| 10 | + include: '**', |
| 11 | + exclude: ['index.md'] |
| 12 | + }, |
| 13 | + schema: z.object({ |
| 14 | + links: z.array(z.object({ |
| 15 | + label: z.string(), |
| 16 | + icon: z.string(), |
| 17 | + to: z.string(), |
| 18 | + target: z.string().optional(), |
| 19 | + variant: z.enum(['link', 'solid', 'outline', 'soft', 'subtle', 'ghost']).optional(), |
| 20 | + alt: z.string().optional() |
| 21 | + })).optional(), |
| 22 | + image: z.object({ src: z.string().nonempty().editor({ input: 'media' }) }), |
| 23 | + authors: z.array( |
| 24 | + z.object({ |
| 25 | + name: z.string().nonempty(), |
| 26 | + to: z.string().nonempty(), |
| 27 | + avatar: z.object({ src: z.string().nonempty().editor({ input: 'media' }) }) |
| 28 | + }) |
| 29 | + ), |
| 30 | + hide: z.boolean().optional(), |
| 31 | + date: z.date(), |
| 32 | + badge: z.object({ label: z.string().nonempty() }), |
| 33 | + // Schema.org structured data - universal approach |
| 34 | + schemaOrg: z.union([ |
| 35 | + // ScholarlyArticle |
| 36 | + z.object({ |
| 37 | + type: z.literal('ScholarlyArticle'), |
| 38 | + headline: z.string().optional(), |
| 39 | + datePublished: z.string().optional(), |
| 40 | + abstract: z.string().optional(), |
| 41 | + image: z.string().optional(), |
| 42 | + publisher: z.union([ |
| 43 | + z.object({ |
| 44 | + type: z.literal('Organization'), |
| 45 | + name: z.string() |
| 46 | + }), |
| 47 | + z.string() |
| 48 | + ]).optional(), |
| 49 | + author: z.array(z.object({ |
78 | 50 | name: z.string(), |
79 | | - url: z.string().optional() |
80 | | - })), |
81 | | - z.object({ |
| 51 | + identifier: z.string().optional(), |
82 | 52 | type: z.literal('Person').optional(), |
83 | | - name: z.string(), |
| 53 | + affiliation: z.string().optional(), |
84 | 54 | url: z.string().optional() |
85 | | - }) |
86 | | - ]).optional(), |
87 | | - datePublished: z.string().optional(), |
88 | | - dateModified: z.string().optional(), |
89 | | - image: z.string().optional(), |
90 | | - description: z.string().optional() |
91 | | - }) |
92 | | - ]).optional() |
| 55 | + })).optional(), |
| 56 | + keywords: z.array(z.string()).optional(), |
| 57 | + mainEntityOfPage: z.string().optional(), |
| 58 | + sameAs: z.string().optional(), |
| 59 | + citation: z.object({ |
| 60 | + type: z.string().optional(), |
| 61 | + name: z.string().optional() |
| 62 | + }).optional() |
| 63 | + }), |
| 64 | + // WebPage (default) |
| 65 | + z.object({ |
| 66 | + type: z.literal('WebPage'), |
| 67 | + headline: z.string().optional(), |
| 68 | + description: z.string().optional(), |
| 69 | + image: z.string().optional(), |
| 70 | + datePublished: z.string().optional(), |
| 71 | + dateModified: z.string().optional() |
| 72 | + }), |
| 73 | + // BlogPosting |
| 74 | + z.object({ |
| 75 | + type: z.literal('BlogPosting'), |
| 76 | + headline: z.string().optional(), |
| 77 | + author: z.union([ |
| 78 | + z.array(z.object({ |
| 79 | + type: z.literal('Person').optional(), |
| 80 | + name: z.string(), |
| 81 | + url: z.string().optional() |
| 82 | + })), |
| 83 | + z.object({ |
| 84 | + type: z.literal('Person').optional(), |
| 85 | + name: z.string(), |
| 86 | + url: z.string().optional() |
| 87 | + }) |
| 88 | + ]).optional(), |
| 89 | + datePublished: z.string().optional(), |
| 90 | + dateModified: z.string().optional(), |
| 91 | + image: z.string().optional(), |
| 92 | + description: z.string().optional() |
| 93 | + }) |
| 94 | + ]).optional() |
| 95 | + }) |
93 | 96 | }) |
94 | | - }) |
| 97 | + ) |
95 | 98 | } |
96 | 99 | }) |
0 commit comments