@nuxtjs/sitemap 7.5.1 → 7.6.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 (85) hide show
  1. package/dist/client/200.html +1 -1
  2. package/dist/client/404.html +1 -1
  3. package/dist/client/_fonts/0xp3SbCWC1OhX7q1-uF6kilMZFm-alJNkUtkLTPCy_A-tN9KwPUWhhXvtqh74sU9FIkI4W6hsbm85r0X24hjOfM.woff2 +0 -0
  4. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-995OEiyou9G2dJsMNn9aLuHTFlgwosm_9gD5SQUWR40.woff +0 -0
  5. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-D6hedAgqRfOCLZzaShnyeAvlEnMzk4Wm7g9WDKWFHIc.woff +0 -0
  6. package/dist/client/_fonts/1ZTlEDqU4DtwDJiND8f6qaugUpa0RIDvQl-v7iM6l54-vrK12kZ24WGUghky9YxsOZpLH8Tt4jMU8XIvzgLQ6DU.woff +0 -0
  7. package/dist/client/_fonts/4HA9tc4y8BVQeLXvLn3JgQqilAj1xrAnUSprQGHIPSw-ZPswEL_UDOYaxTLQDUySPjoOHDxhD83pD19HMfKfK9s.woff2 +0 -0
  8. package/dist/client/_fonts/Bmul3LaKlc7BUKqJHE_UmEoF40Sg_2ga52yJjwyDcKs-TnYmYl1DNYkiWMu0Vx49DakCPBuiCCj9zoLIuQjUdKY.woff2 +0 -0
  9. package/dist/client/_fonts/DfgmjWGpWte3Q3a54Nevr_BYmMM5YEJXRI1CdI2VwO0-ox5RadQfCyVTmKl_hubTaIJjtRw9oaQz2GDBeZR6l1M.woff2 +0 -0
  10. package/dist/client/_fonts/LK8hREFNeTe-EIzvbfgusJBg3CJ7Q7NFgYIiGb2LZ8-qiyWl0ATLJjOsRPZC_7a8mTMFxEMKEv6JTK_kHtMzbM.woff2 +0 -0
  11. package/dist/client/_fonts/Lc_5lWuBuZcZ166p1-s-mnGkMJwIYJE_QDCkws8iCkI-r45Qbm2hCykrfOZ0kowz__uTTTUOPDN9hz34QcRNTY4.woff2 +0 -0
  12. package/dist/client/_fonts/UBlOS9e0BmJuiF5yVs0YcJrFWaa-iN8zx9TP_lmKs8c-iH3Naewt5UjJ0AQ38QZs4lkEo4zdjMIVkLs4y7EiwIE.woff2 +0 -0
  13. package/dist/client/_fonts/gRxGIWazSFZVyzU0s62U9IArK3RJLkOoUmXx0C8Npsw-kMFNQG6iwjw2nvqS3ut9jMSVn__HlJ28slvxjE4hYfc.woff2 +0 -0
  14. package/dist/client/_fonts/hIKtJJBMNYGPUppSYZpyuF6c24cKhBkhsgaCTgzYgqw-jRJyBPlfGDXClyrgfO6GK_Pfs1RmTsB-wWX6MOgpsRA.woff2 +0 -0
  15. package/dist/client/_fonts/iEvApgDRmzKzNqOYocBTrmcHZmuGAJloawKDP1S0nyE-T3oc_9We24QGwfw5naik4cM0g7VxylWVaQwKm4dy3cw.woff2 +0 -0
  16. package/dist/client/_fonts/kokcBTWRechd97ZdVUpUxrOFbsRt8whO21yA1vQ6iJ8-O7CCbVvFgg_MFLTdyFF9FMeMvIoEmxJLubqVDYTUoWY.woff2 +0 -0
  17. package/dist/client/_fonts/oFzdhjQtZFydTZ757bmiVFXgReR2bBSYm_CjQ7B1Jjs-F6oFbDhOWKYJbgrlC93wkLkPlIV7mzgvqwqEDxQMeHA.woff2 +0 -0
  18. package/dist/client/_nuxt/5ZF0DUKe.js +1 -0
  19. package/dist/client/_nuxt/8XcEHgiq.js +1 -0
  20. package/dist/client/_nuxt/B2G1Husz.js +1 -0
  21. package/dist/client/_nuxt/B6Rjxwce.js +1 -0
  22. package/dist/client/_nuxt/BTnenz-7.js +1 -0
  23. package/dist/client/_nuxt/BaarzCY9.js +181 -0
  24. package/dist/client/_nuxt/BeMtTGFX.js +1 -0
  25. package/dist/client/_nuxt/BgRd_GNf.js +1 -0
  26. package/dist/client/_nuxt/Bj_3pTUi.js +1 -0
  27. package/dist/client/_nuxt/BqgETAYZ.js +1 -0
  28. package/dist/client/_nuxt/C1-eNu7x.js +1 -0
  29. package/dist/client/_nuxt/C6MORWr4.js +1 -0
  30. package/dist/client/_nuxt/CIJ7g9su.js +1 -0
  31. package/dist/client/_nuxt/CINkxRg5.js +1 -0
  32. package/dist/client/_nuxt/COIEcBZR.js +1 -0
  33. package/dist/client/_nuxt/CZ3hLIr1.js +1 -0
  34. package/dist/client/_nuxt/Caedg1qp.js +1 -0
  35. package/dist/client/_nuxt/Cmw_hYOm.js +1 -0
  36. package/dist/client/_nuxt/CxFX6b0M.js +1 -0
  37. package/dist/client/_nuxt/D4YjxrHq.js +1 -0
  38. package/dist/client/_nuxt/DHOdika3.js +1 -0
  39. package/dist/client/_nuxt/DSdw0YSI.js +1 -0
  40. package/dist/client/_nuxt/DSxZHkX-.js +1 -0
  41. package/dist/client/_nuxt/Dn8lRF86.js +1 -0
  42. package/dist/client/_nuxt/DwNiGCgn.js +1 -0
  43. package/dist/client/_nuxt/O3qB0pnO.js +1 -0
  44. package/dist/client/_nuxt/ProsePre.D5orA6B_.css +1 -0
  45. package/dist/client/_nuxt/ZdghZ1ke.js +1 -0
  46. package/dist/client/_nuxt/aUtIlT-b.js +1 -0
  47. package/dist/client/_nuxt/builds/latest.json +1 -1
  48. package/dist/client/_nuxt/builds/meta/6319eec7-8aee-40f4-abcf-31c51d4b20a5.json +1 -0
  49. package/dist/client/_nuxt/entry.D1qdnVLM.css +1 -0
  50. package/dist/client/_nuxt/error-404.BBebgf1Y.css +1 -0
  51. package/dist/client/_nuxt/error-500.C4WF4yER.css +1 -0
  52. package/dist/client/index.html +1 -1
  53. package/dist/content.d.mts +56 -194
  54. package/dist/content.d.ts +56 -194
  55. package/dist/content.mjs +15 -1
  56. package/dist/module.json +1 -1
  57. package/dist/module.mjs +134 -59
  58. package/dist/runtime/server/plugins/compression.js +18 -3
  59. package/dist/runtime/server/routes/__sitemap__/debug.d.ts +2 -2
  60. package/dist/runtime/server/routes/__sitemap__/debug.js +21 -2
  61. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.d.ts +1 -3
  62. package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.js +22 -10
  63. package/dist/runtime/server/routes/sitemap.xsl.js +345 -149
  64. package/dist/runtime/server/sitemap/builder/sitemap.js +16 -1
  65. package/dist/runtime/server/sitemap/builder/xml.js +4 -0
  66. package/dist/runtime/server/sitemap/event-handlers.js +12 -3
  67. package/dist/runtime/server/sitemap/nitro.js +12 -3
  68. package/dist/runtime/server/sitemap/urlset/normalise.d.ts +2 -1
  69. package/dist/runtime/server/sitemap/urlset/normalise.js +24 -0
  70. package/dist/runtime/server/sitemap/urlset/sources.js +1 -1
  71. package/dist/runtime/types.d.ts +9 -0
  72. package/dist/utils.d.mts +13 -2
  73. package/dist/utils.d.ts +13 -2
  74. package/dist/utils.mjs +54 -1
  75. package/package.json +18 -19
  76. package/dist/client/__sitemap__/style.xsl +0 -190
  77. package/dist/client/_nuxt/BZzBMR0a.js +0 -155
  78. package/dist/client/_nuxt/BcLzIRTJ.js +0 -1
  79. package/dist/client/_nuxt/CQIolwG-.js +0 -1
  80. package/dist/client/_nuxt/builds/meta/c9c08595-dc8d-4073-931c-6ba959692bc1.json +0 -1
  81. package/dist/client/_nuxt/entry.Ci1pP-eR.css +0 -1
  82. package/dist/client/_nuxt/error-404.DKXSOdpM.css +0 -1
  83. package/dist/client/_nuxt/error-500.rUXo3Kq4.css +0 -1
  84. package/dist/client/sitemap.xml +0 -7
  85. package/virtual.d.ts +0 -15
@@ -1,11 +1,15 @@
1
- import { Collection } from '@nuxt/content';
1
+ import { PageCollectionItemBase, Collection } from '@nuxt/content';
2
2
  import { z, TypeOf } from 'zod';
3
3
 
4
+ declare global {
5
+ var __sitemapCollectionFilters: Map<string, (entry: any) => boolean> | undefined;
6
+ var __sitemapCollectionOnUrlFns: Map<string, (url: any, entry: any, collection: string) => void> | undefined;
7
+ }
4
8
  declare const schema: z.ZodObject<{
5
9
  sitemap: z.ZodOptional<z.ZodObject<{
6
10
  loc: z.ZodOptional<z.ZodString>;
7
11
  lastmod: z.ZodOptional<z.ZodDate>;
8
- changefreq: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"hourly">, z.ZodLiteral<"daily">, z.ZodLiteral<"weekly">, z.ZodLiteral<"monthly">, z.ZodLiteral<"yearly">, z.ZodLiteral<"never">]>>;
12
+ changefreq: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"hourly">, z.ZodLiteral<"daily">, z.ZodLiteral<"weekly">, z.ZodLiteral<"monthly">, z.ZodLiteral<"yearly">, z.ZodLiteral<"never">]>>;
9
13
  priority: z.ZodOptional<z.ZodNumber>;
10
14
  images: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
15
  loc: z.ZodString;
@@ -13,19 +17,7 @@ declare const schema: z.ZodObject<{
13
17
  geo_location: z.ZodOptional<z.ZodString>;
14
18
  title: z.ZodOptional<z.ZodString>;
15
19
  license: z.ZodOptional<z.ZodString>;
16
- }, "strip", z.ZodTypeAny, {
17
- loc: string;
18
- caption?: string | undefined;
19
- geo_location?: string | undefined;
20
- title?: string | undefined;
21
- license?: string | undefined;
22
- }, {
23
- loc: string;
24
- caption?: string | undefined;
25
- geo_location?: string | undefined;
26
- title?: string | undefined;
27
- license?: string | undefined;
28
- }>, "many">>;
20
+ }, z.core.$strip>>>;
29
21
  videos: z.ZodOptional<z.ZodArray<z.ZodObject<{
30
22
  content_loc: z.ZodString;
31
23
  player_loc: z.ZodOptional<z.ZodString>;
@@ -40,192 +32,62 @@ declare const schema: z.ZodObject<{
40
32
  restriction: z.ZodOptional<z.ZodObject<{
41
33
  relationship: z.ZodOptional<z.ZodLiteral<"allow">>;
42
34
  value: z.ZodOptional<z.ZodString>;
43
- }, "strip", z.ZodTypeAny, {
44
- value?: string | undefined;
45
- relationship?: "allow" | undefined;
46
- }, {
47
- value?: string | undefined;
48
- relationship?: "allow" | undefined;
49
- }>>;
35
+ }, z.core.$strip>>;
50
36
  gallery_loc: z.ZodOptional<z.ZodString>;
51
37
  price: z.ZodOptional<z.ZodString>;
52
38
  requires_subscription: z.ZodOptional<z.ZodBoolean>;
53
39
  uploader: z.ZodOptional<z.ZodString>;
54
- }, "strip", z.ZodTypeAny, {
55
- content_loc: string;
56
- player_loc?: string | undefined;
57
- duration?: string | undefined;
58
- expiration_date?: Date | undefined;
59
- rating?: number | undefined;
60
- view_count?: number | undefined;
61
- publication_date?: Date | undefined;
62
- family_friendly?: boolean | undefined;
63
- tag?: string | undefined;
64
- category?: string | undefined;
65
- restriction?: {
66
- value?: string | undefined;
67
- relationship?: "allow" | undefined;
68
- } | undefined;
69
- gallery_loc?: string | undefined;
70
- price?: string | undefined;
71
- requires_subscription?: boolean | undefined;
72
- uploader?: string | undefined;
73
- }, {
74
- content_loc: string;
75
- player_loc?: string | undefined;
76
- duration?: string | undefined;
77
- expiration_date?: Date | undefined;
78
- rating?: number | undefined;
79
- view_count?: number | undefined;
80
- publication_date?: Date | undefined;
81
- family_friendly?: boolean | undefined;
82
- tag?: string | undefined;
83
- category?: string | undefined;
84
- restriction?: {
85
- value?: string | undefined;
86
- relationship?: "allow" | undefined;
87
- } | undefined;
88
- gallery_loc?: string | undefined;
89
- price?: string | undefined;
90
- requires_subscription?: boolean | undefined;
91
- uploader?: string | undefined;
92
- }>, "many">>;
93
- }, "strip", z.ZodTypeAny, {
94
- loc?: string | undefined;
95
- lastmod?: Date | undefined;
96
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
97
- priority?: number | undefined;
98
- images?: {
99
- loc: string;
100
- caption?: string | undefined;
101
- geo_location?: string | undefined;
102
- title?: string | undefined;
103
- license?: string | undefined;
104
- }[] | undefined;
105
- videos?: {
106
- content_loc: string;
107
- player_loc?: string | undefined;
108
- duration?: string | undefined;
109
- expiration_date?: Date | undefined;
110
- rating?: number | undefined;
111
- view_count?: number | undefined;
112
- publication_date?: Date | undefined;
113
- family_friendly?: boolean | undefined;
114
- tag?: string | undefined;
115
- category?: string | undefined;
116
- restriction?: {
117
- value?: string | undefined;
118
- relationship?: "allow" | undefined;
119
- } | undefined;
120
- gallery_loc?: string | undefined;
121
- price?: string | undefined;
122
- requires_subscription?: boolean | undefined;
123
- uploader?: string | undefined;
124
- }[] | undefined;
125
- }, {
126
- loc?: string | undefined;
127
- lastmod?: Date | undefined;
128
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
129
- priority?: number | undefined;
130
- images?: {
131
- loc: string;
132
- caption?: string | undefined;
133
- geo_location?: string | undefined;
134
- title?: string | undefined;
135
- license?: string | undefined;
136
- }[] | undefined;
137
- videos?: {
138
- content_loc: string;
139
- player_loc?: string | undefined;
140
- duration?: string | undefined;
141
- expiration_date?: Date | undefined;
142
- rating?: number | undefined;
143
- view_count?: number | undefined;
144
- publication_date?: Date | undefined;
145
- family_friendly?: boolean | undefined;
146
- tag?: string | undefined;
147
- category?: string | undefined;
148
- restriction?: {
149
- value?: string | undefined;
150
- relationship?: "allow" | undefined;
151
- } | undefined;
152
- gallery_loc?: string | undefined;
153
- price?: string | undefined;
154
- requires_subscription?: boolean | undefined;
155
- uploader?: string | undefined;
156
- }[] | undefined;
157
- }>>;
158
- }, "strip", z.ZodTypeAny, {
159
- sitemap?: {
160
- loc?: string | undefined;
161
- lastmod?: Date | undefined;
162
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
163
- priority?: number | undefined;
164
- images?: {
165
- loc: string;
166
- caption?: string | undefined;
167
- geo_location?: string | undefined;
168
- title?: string | undefined;
169
- license?: string | undefined;
170
- }[] | undefined;
171
- videos?: {
172
- content_loc: string;
173
- player_loc?: string | undefined;
174
- duration?: string | undefined;
175
- expiration_date?: Date | undefined;
176
- rating?: number | undefined;
177
- view_count?: number | undefined;
178
- publication_date?: Date | undefined;
179
- family_friendly?: boolean | undefined;
180
- tag?: string | undefined;
181
- category?: string | undefined;
182
- restriction?: {
183
- value?: string | undefined;
184
- relationship?: "allow" | undefined;
185
- } | undefined;
186
- gallery_loc?: string | undefined;
187
- price?: string | undefined;
188
- requires_subscription?: boolean | undefined;
189
- uploader?: string | undefined;
190
- }[] | undefined;
191
- } | undefined;
192
- }, {
193
- sitemap?: {
194
- loc?: string | undefined;
195
- lastmod?: Date | undefined;
196
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
197
- priority?: number | undefined;
40
+ }, z.core.$strip>>>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ type SitemapSchema = TypeOf<typeof schema>;
44
+ interface AsSitemapCollectionOptions<TEntry = Record<string, unknown>> {
45
+ /**
46
+ * Collection name. Must match the key in your collections object.
47
+ * Required when using `filter` or `onUrl`.
48
+ * @example
49
+ * collections: {
50
+ * blog: defineCollection(asSitemapCollection({...}, { name: 'blog', filter: ... }))
51
+ * }
52
+ */
53
+ name?: string;
54
+ /**
55
+ * Runtime filter function to exclude entries from sitemap.
56
+ * Receives the full content entry including all schema fields.
57
+ * Requires `name` parameter to be set.
58
+ * @example
59
+ * { name: 'blog', filter: (entry) => !entry.draft && new Date(entry.date) <= new Date() }
60
+ */
61
+ filter?: (entry: PageCollectionItemBase & SitemapSchema & TEntry) => boolean;
62
+ /**
63
+ * Transform the sitemap URL entry for each item in this collection.
64
+ * Mutate `url` directly to change `loc`, `lastmod`, `priority`, etc.
65
+ * The full content entry and collection name are provided for context.
66
+ * Useful when the collection uses `prefix: ''` in its source config,
67
+ * which strips the directory prefix from content paths.
68
+ * Requires `name` parameter to be set.
69
+ * @example
70
+ * // Add a locale prefix
71
+ * { name: 'content_zh', onUrl: (url) => { url.loc = `/zh${url.loc}` } }
72
+ * @example
73
+ * // Use content entry fields to set priority
74
+ * { name: 'blog', onUrl: (url, entry) => { url.priority = entry.featured ? 1.0 : 0.5 } }
75
+ */
76
+ onUrl?: (url: {
77
+ loc: string;
78
+ lastmod?: string | Date;
79
+ changefreq?: string;
80
+ priority?: number;
198
81
  images?: {
199
82
  loc: string;
200
- caption?: string | undefined;
201
- geo_location?: string | undefined;
202
- title?: string | undefined;
203
- license?: string | undefined;
204
- }[] | undefined;
83
+ }[];
205
84
  videos?: {
206
85
  content_loc: string;
207
- player_loc?: string | undefined;
208
- duration?: string | undefined;
209
- expiration_date?: Date | undefined;
210
- rating?: number | undefined;
211
- view_count?: number | undefined;
212
- publication_date?: Date | undefined;
213
- family_friendly?: boolean | undefined;
214
- tag?: string | undefined;
215
- category?: string | undefined;
216
- restriction?: {
217
- value?: string | undefined;
218
- relationship?: "allow" | undefined;
219
- } | undefined;
220
- gallery_loc?: string | undefined;
221
- price?: string | undefined;
222
- requires_subscription?: boolean | undefined;
223
- uploader?: string | undefined;
224
- }[] | undefined;
225
- } | undefined;
226
- }>;
227
- type SitemapSchema = TypeOf<typeof schema>;
228
- declare function asSitemapCollection<T>(collection: Collection<T>): Collection<T>;
86
+ }[];
87
+ [key: string]: unknown;
88
+ }, entry: PageCollectionItemBase & SitemapSchema & TEntry, collection: string) => void;
89
+ }
90
+ declare function asSitemapCollection<T>(collection: Collection<T>, options?: AsSitemapCollectionOptions<T>): Collection<T>;
229
91
 
230
92
  export { asSitemapCollection, schema };
231
- export type { SitemapSchema };
93
+ export type { AsSitemapCollectionOptions, SitemapSchema };
package/dist/content.d.ts CHANGED
@@ -1,11 +1,15 @@
1
- import { Collection } from '@nuxt/content';
1
+ import { PageCollectionItemBase, Collection } from '@nuxt/content';
2
2
  import { z, TypeOf } from 'zod';
3
3
 
4
+ declare global {
5
+ var __sitemapCollectionFilters: Map<string, (entry: any) => boolean> | undefined;
6
+ var __sitemapCollectionOnUrlFns: Map<string, (url: any, entry: any, collection: string) => void> | undefined;
7
+ }
4
8
  declare const schema: z.ZodObject<{
5
9
  sitemap: z.ZodOptional<z.ZodObject<{
6
10
  loc: z.ZodOptional<z.ZodString>;
7
11
  lastmod: z.ZodOptional<z.ZodDate>;
8
- changefreq: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"always">, z.ZodLiteral<"hourly">, z.ZodLiteral<"daily">, z.ZodLiteral<"weekly">, z.ZodLiteral<"monthly">, z.ZodLiteral<"yearly">, z.ZodLiteral<"never">]>>;
12
+ changefreq: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"always">, z.ZodLiteral<"hourly">, z.ZodLiteral<"daily">, z.ZodLiteral<"weekly">, z.ZodLiteral<"monthly">, z.ZodLiteral<"yearly">, z.ZodLiteral<"never">]>>;
9
13
  priority: z.ZodOptional<z.ZodNumber>;
10
14
  images: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
15
  loc: z.ZodString;
@@ -13,19 +17,7 @@ declare const schema: z.ZodObject<{
13
17
  geo_location: z.ZodOptional<z.ZodString>;
14
18
  title: z.ZodOptional<z.ZodString>;
15
19
  license: z.ZodOptional<z.ZodString>;
16
- }, "strip", z.ZodTypeAny, {
17
- loc: string;
18
- caption?: string | undefined;
19
- geo_location?: string | undefined;
20
- title?: string | undefined;
21
- license?: string | undefined;
22
- }, {
23
- loc: string;
24
- caption?: string | undefined;
25
- geo_location?: string | undefined;
26
- title?: string | undefined;
27
- license?: string | undefined;
28
- }>, "many">>;
20
+ }, z.core.$strip>>>;
29
21
  videos: z.ZodOptional<z.ZodArray<z.ZodObject<{
30
22
  content_loc: z.ZodString;
31
23
  player_loc: z.ZodOptional<z.ZodString>;
@@ -40,192 +32,62 @@ declare const schema: z.ZodObject<{
40
32
  restriction: z.ZodOptional<z.ZodObject<{
41
33
  relationship: z.ZodOptional<z.ZodLiteral<"allow">>;
42
34
  value: z.ZodOptional<z.ZodString>;
43
- }, "strip", z.ZodTypeAny, {
44
- value?: string | undefined;
45
- relationship?: "allow" | undefined;
46
- }, {
47
- value?: string | undefined;
48
- relationship?: "allow" | undefined;
49
- }>>;
35
+ }, z.core.$strip>>;
50
36
  gallery_loc: z.ZodOptional<z.ZodString>;
51
37
  price: z.ZodOptional<z.ZodString>;
52
38
  requires_subscription: z.ZodOptional<z.ZodBoolean>;
53
39
  uploader: z.ZodOptional<z.ZodString>;
54
- }, "strip", z.ZodTypeAny, {
55
- content_loc: string;
56
- player_loc?: string | undefined;
57
- duration?: string | undefined;
58
- expiration_date?: Date | undefined;
59
- rating?: number | undefined;
60
- view_count?: number | undefined;
61
- publication_date?: Date | undefined;
62
- family_friendly?: boolean | undefined;
63
- tag?: string | undefined;
64
- category?: string | undefined;
65
- restriction?: {
66
- value?: string | undefined;
67
- relationship?: "allow" | undefined;
68
- } | undefined;
69
- gallery_loc?: string | undefined;
70
- price?: string | undefined;
71
- requires_subscription?: boolean | undefined;
72
- uploader?: string | undefined;
73
- }, {
74
- content_loc: string;
75
- player_loc?: string | undefined;
76
- duration?: string | undefined;
77
- expiration_date?: Date | undefined;
78
- rating?: number | undefined;
79
- view_count?: number | undefined;
80
- publication_date?: Date | undefined;
81
- family_friendly?: boolean | undefined;
82
- tag?: string | undefined;
83
- category?: string | undefined;
84
- restriction?: {
85
- value?: string | undefined;
86
- relationship?: "allow" | undefined;
87
- } | undefined;
88
- gallery_loc?: string | undefined;
89
- price?: string | undefined;
90
- requires_subscription?: boolean | undefined;
91
- uploader?: string | undefined;
92
- }>, "many">>;
93
- }, "strip", z.ZodTypeAny, {
94
- loc?: string | undefined;
95
- lastmod?: Date | undefined;
96
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
97
- priority?: number | undefined;
98
- images?: {
99
- loc: string;
100
- caption?: string | undefined;
101
- geo_location?: string | undefined;
102
- title?: string | undefined;
103
- license?: string | undefined;
104
- }[] | undefined;
105
- videos?: {
106
- content_loc: string;
107
- player_loc?: string | undefined;
108
- duration?: string | undefined;
109
- expiration_date?: Date | undefined;
110
- rating?: number | undefined;
111
- view_count?: number | undefined;
112
- publication_date?: Date | undefined;
113
- family_friendly?: boolean | undefined;
114
- tag?: string | undefined;
115
- category?: string | undefined;
116
- restriction?: {
117
- value?: string | undefined;
118
- relationship?: "allow" | undefined;
119
- } | undefined;
120
- gallery_loc?: string | undefined;
121
- price?: string | undefined;
122
- requires_subscription?: boolean | undefined;
123
- uploader?: string | undefined;
124
- }[] | undefined;
125
- }, {
126
- loc?: string | undefined;
127
- lastmod?: Date | undefined;
128
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
129
- priority?: number | undefined;
130
- images?: {
131
- loc: string;
132
- caption?: string | undefined;
133
- geo_location?: string | undefined;
134
- title?: string | undefined;
135
- license?: string | undefined;
136
- }[] | undefined;
137
- videos?: {
138
- content_loc: string;
139
- player_loc?: string | undefined;
140
- duration?: string | undefined;
141
- expiration_date?: Date | undefined;
142
- rating?: number | undefined;
143
- view_count?: number | undefined;
144
- publication_date?: Date | undefined;
145
- family_friendly?: boolean | undefined;
146
- tag?: string | undefined;
147
- category?: string | undefined;
148
- restriction?: {
149
- value?: string | undefined;
150
- relationship?: "allow" | undefined;
151
- } | undefined;
152
- gallery_loc?: string | undefined;
153
- price?: string | undefined;
154
- requires_subscription?: boolean | undefined;
155
- uploader?: string | undefined;
156
- }[] | undefined;
157
- }>>;
158
- }, "strip", z.ZodTypeAny, {
159
- sitemap?: {
160
- loc?: string | undefined;
161
- lastmod?: Date | undefined;
162
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
163
- priority?: number | undefined;
164
- images?: {
165
- loc: string;
166
- caption?: string | undefined;
167
- geo_location?: string | undefined;
168
- title?: string | undefined;
169
- license?: string | undefined;
170
- }[] | undefined;
171
- videos?: {
172
- content_loc: string;
173
- player_loc?: string | undefined;
174
- duration?: string | undefined;
175
- expiration_date?: Date | undefined;
176
- rating?: number | undefined;
177
- view_count?: number | undefined;
178
- publication_date?: Date | undefined;
179
- family_friendly?: boolean | undefined;
180
- tag?: string | undefined;
181
- category?: string | undefined;
182
- restriction?: {
183
- value?: string | undefined;
184
- relationship?: "allow" | undefined;
185
- } | undefined;
186
- gallery_loc?: string | undefined;
187
- price?: string | undefined;
188
- requires_subscription?: boolean | undefined;
189
- uploader?: string | undefined;
190
- }[] | undefined;
191
- } | undefined;
192
- }, {
193
- sitemap?: {
194
- loc?: string | undefined;
195
- lastmod?: Date | undefined;
196
- changefreq?: "never" | "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | undefined;
197
- priority?: number | undefined;
40
+ }, z.core.$strip>>>;
41
+ }, z.core.$strip>>;
42
+ }, z.core.$strip>;
43
+ type SitemapSchema = TypeOf<typeof schema>;
44
+ interface AsSitemapCollectionOptions<TEntry = Record<string, unknown>> {
45
+ /**
46
+ * Collection name. Must match the key in your collections object.
47
+ * Required when using `filter` or `onUrl`.
48
+ * @example
49
+ * collections: {
50
+ * blog: defineCollection(asSitemapCollection({...}, { name: 'blog', filter: ... }))
51
+ * }
52
+ */
53
+ name?: string;
54
+ /**
55
+ * Runtime filter function to exclude entries from sitemap.
56
+ * Receives the full content entry including all schema fields.
57
+ * Requires `name` parameter to be set.
58
+ * @example
59
+ * { name: 'blog', filter: (entry) => !entry.draft && new Date(entry.date) <= new Date() }
60
+ */
61
+ filter?: (entry: PageCollectionItemBase & SitemapSchema & TEntry) => boolean;
62
+ /**
63
+ * Transform the sitemap URL entry for each item in this collection.
64
+ * Mutate `url` directly to change `loc`, `lastmod`, `priority`, etc.
65
+ * The full content entry and collection name are provided for context.
66
+ * Useful when the collection uses `prefix: ''` in its source config,
67
+ * which strips the directory prefix from content paths.
68
+ * Requires `name` parameter to be set.
69
+ * @example
70
+ * // Add a locale prefix
71
+ * { name: 'content_zh', onUrl: (url) => { url.loc = `/zh${url.loc}` } }
72
+ * @example
73
+ * // Use content entry fields to set priority
74
+ * { name: 'blog', onUrl: (url, entry) => { url.priority = entry.featured ? 1.0 : 0.5 } }
75
+ */
76
+ onUrl?: (url: {
77
+ loc: string;
78
+ lastmod?: string | Date;
79
+ changefreq?: string;
80
+ priority?: number;
198
81
  images?: {
199
82
  loc: string;
200
- caption?: string | undefined;
201
- geo_location?: string | undefined;
202
- title?: string | undefined;
203
- license?: string | undefined;
204
- }[] | undefined;
83
+ }[];
205
84
  videos?: {
206
85
  content_loc: string;
207
- player_loc?: string | undefined;
208
- duration?: string | undefined;
209
- expiration_date?: Date | undefined;
210
- rating?: number | undefined;
211
- view_count?: number | undefined;
212
- publication_date?: Date | undefined;
213
- family_friendly?: boolean | undefined;
214
- tag?: string | undefined;
215
- category?: string | undefined;
216
- restriction?: {
217
- value?: string | undefined;
218
- relationship?: "allow" | undefined;
219
- } | undefined;
220
- gallery_loc?: string | undefined;
221
- price?: string | undefined;
222
- requires_subscription?: boolean | undefined;
223
- uploader?: string | undefined;
224
- }[] | undefined;
225
- } | undefined;
226
- }>;
227
- type SitemapSchema = TypeOf<typeof schema>;
228
- declare function asSitemapCollection<T>(collection: Collection<T>): Collection<T>;
86
+ }[];
87
+ [key: string]: unknown;
88
+ }, entry: PageCollectionItemBase & SitemapSchema & TEntry, collection: string) => void;
89
+ }
90
+ declare function asSitemapCollection<T>(collection: Collection<T>, options?: AsSitemapCollectionOptions<T>): Collection<T>;
229
91
 
230
92
  export { asSitemapCollection, schema };
231
- export type { SitemapSchema };
93
+ export type { AsSitemapCollectionOptions, SitemapSchema };
package/dist/content.mjs CHANGED
@@ -1,5 +1,11 @@
1
1
  import { z } from 'zod';
2
2
 
3
+ if (!globalThis.__sitemapCollectionFilters)
4
+ globalThis.__sitemapCollectionFilters = /* @__PURE__ */ new Map();
5
+ if (!globalThis.__sitemapCollectionOnUrlFns)
6
+ globalThis.__sitemapCollectionOnUrlFns = /* @__PURE__ */ new Map();
7
+ const collectionFilters = globalThis.__sitemapCollectionFilters;
8
+ const collectionOnUrlFns = globalThis.__sitemapCollectionOnUrlFns;
3
9
  const schema = z.object({
4
10
  sitemap: z.object({
5
11
  loc: z.string().optional(),
@@ -35,9 +41,17 @@ const schema = z.object({
35
41
  })).optional()
36
42
  }).optional()
37
43
  });
38
- function asSitemapCollection(collection) {
44
+ function asSitemapCollection(collection, options) {
39
45
  if (collection.type === "page") {
40
46
  collection.schema = collection.schema ? schema.extend(collection.schema.shape) : schema;
47
+ if (options?.filter || options?.onUrl) {
48
+ if (!options.name)
49
+ throw new Error("[sitemap] `name` is required when using `filter` or `onUrl` in asSitemapCollection()");
50
+ if (options.filter)
51
+ collectionFilters.set(options.name, options.filter);
52
+ if (options.onUrl)
53
+ collectionOnUrlFns.set(options.name, options.onUrl);
54
+ }
41
55
  }
42
56
  return collection;
43
57
  }
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "nuxt": ">=3.9.0"
5
5
  },
6
6
  "configKey": "sitemap",
7
- "version": "7.5.1",
7
+ "version": "7.6.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"