@nuxtjs/sitemap 7.4.5 → 7.4.8
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 +1 -1
- package/dist/client/200.html +1 -0
- package/dist/client/404.html +1 -0
- package/dist/client/__sitemap__/style.xsl +190 -0
- package/dist/client/_nuxt/BD3NqoLn.js +1 -0
- package/dist/client/_nuxt/CGPPaMu7.js +1 -0
- package/dist/client/_nuxt/CVO1_9PV.js +1 -0
- package/dist/client/_nuxt/Cp-IABpG.js +1 -0
- package/dist/client/_nuxt/D0r3Knsf.js +1 -0
- package/dist/client/_nuxt/HdjdXzAy.js +157 -0
- package/dist/client/_nuxt/builds/latest.json +1 -0
- package/dist/client/_nuxt/builds/meta/61bb4b51-7d01-424f-91fb-0e4ca01f7b22.json +1 -0
- package/dist/client/_nuxt/entry.Ci1pP-eR.css +1 -0
- package/dist/client/_nuxt/error-404.i2ufnNET.css +1 -0
- package/dist/client/_nuxt/error-500.CIrNTbBE.css +1 -0
- package/dist/client/index.html +1 -0
- package/dist/client/sitemap.xml +7 -0
- package/dist/content.d.mts +232 -0
- package/dist/content.d.ts +232 -0
- package/dist/content.mjs +45 -0
- package/dist/module.d.mts +10 -0
- package/dist/module.d.ts +10 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +1270 -0
- package/dist/runtime/server/composables/asSitemapUrl.d.ts +2 -0
- package/dist/runtime/server/composables/asSitemapUrl.js +3 -0
- package/dist/runtime/server/composables/defineSitemapEventHandler.d.ts +4 -0
- package/dist/runtime/server/composables/defineSitemapEventHandler.js +2 -0
- package/dist/runtime/server/content-compat.d.ts +1 -0
- package/dist/runtime/server/content-compat.js +2 -0
- package/dist/runtime/server/kit.d.ts +3 -0
- package/dist/runtime/server/kit.js +25 -0
- package/dist/runtime/server/plugins/compression.d.ts +2 -0
- package/dist/runtime/server/plugins/compression.js +8 -0
- package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +2 -0
- package/dist/runtime/server/plugins/nuxt-content-v2.js +39 -0
- package/dist/runtime/server/plugins/warm-up.d.ts +2 -0
- package/dist/runtime/server/plugins/warm-up.js +39 -0
- package/dist/runtime/server/robots-polyfill/getPathRobotConfig.d.ts +5 -0
- package/dist/runtime/server/robots-polyfill/getPathRobotConfig.js +3 -0
- package/dist/runtime/server/routes/__sitemap__/debug.d.ts +45 -0
- package/dist/runtime/server/routes/__sitemap__/debug.js +31 -0
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.d.ts +2 -0
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.js +6 -0
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.d.ts +2 -0
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.js +24 -0
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.js +50 -0
- package/dist/runtime/server/routes/sitemap.xml.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.xml.js +13 -0
- package/dist/runtime/server/routes/sitemap.xsl.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.xsl.js +255 -0
- package/dist/runtime/server/routes/sitemap_index.xml.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap_index.xml.js +42 -0
- package/dist/runtime/server/sitemap/builder/sitemap-index.d.ts +13 -0
- package/dist/runtime/server/sitemap/builder/sitemap-index.js +197 -0
- package/dist/runtime/server/sitemap/builder/sitemap.d.ts +16 -0
- package/dist/runtime/server/sitemap/builder/sitemap.js +243 -0
- package/dist/runtime/server/sitemap/builder/xml.d.ts +6 -0
- package/dist/runtime/server/sitemap/builder/xml.js +197 -0
- package/dist/runtime/server/sitemap/nitro.d.ts +4 -0
- package/dist/runtime/server/sitemap/nitro.js +144 -0
- package/dist/runtime/server/sitemap/urlset/normalise.d.ts +6 -0
- package/dist/runtime/server/sitemap/urlset/normalise.js +137 -0
- package/dist/runtime/server/sitemap/urlset/sort.d.ts +2 -0
- package/dist/runtime/server/sitemap/urlset/sort.js +13 -0
- package/dist/runtime/server/sitemap/urlset/sources.d.ts +6 -0
- package/dist/runtime/server/sitemap/urlset/sources.js +159 -0
- package/dist/runtime/server/sitemap/utils/chunk.d.ts +10 -0
- package/dist/runtime/server/sitemap/utils/chunk.js +67 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils.d.ts +5 -0
- package/dist/runtime/server/utils.js +16 -0
- package/dist/runtime/types.d.ts +458 -0
- package/dist/runtime/types.js +0 -0
- package/dist/runtime/utils-pure.d.ts +14 -0
- package/dist/runtime/utils-pure.js +85 -0
- package/dist/shared/sitemap.Bj0OAEtK.mjs +223 -0
- package/dist/types.d.mts +5 -0
- package/dist/utils.d.mts +28 -0
- package/dist/utils.d.ts +28 -0
- package/dist/utils.mjs +368 -0
- package/package.json +25 -25
- package/virtual.d.ts +4 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModuleRuntimeConfig, SitemapDefinition } from '../../../types.js';
|
|
2
|
+
export interface ChunkInfo {
|
|
3
|
+
isChunked: boolean;
|
|
4
|
+
baseSitemapName: string;
|
|
5
|
+
chunkIndex?: number;
|
|
6
|
+
chunkSize: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function parseChunkInfo(sitemapName: string, sitemaps: ModuleRuntimeConfig['sitemaps'], defaultChunkSize?: number | false): ChunkInfo;
|
|
9
|
+
export declare function getSitemapConfig(sitemapName: string, sitemaps: ModuleRuntimeConfig['sitemaps'], defaultChunkSize?: number): SitemapDefinition;
|
|
10
|
+
export declare function sliceUrlsForChunk<T>(urls: T[], sitemapName: string, sitemaps: ModuleRuntimeConfig['sitemaps'], defaultChunkSize?: number): T[];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export function parseChunkInfo(sitemapName, sitemaps, defaultChunkSize) {
|
|
2
|
+
defaultChunkSize = defaultChunkSize || 1e3;
|
|
3
|
+
if (typeof sitemaps.chunks !== "undefined" && !Number.isNaN(Number(sitemapName))) {
|
|
4
|
+
return {
|
|
5
|
+
isChunked: true,
|
|
6
|
+
baseSitemapName: "sitemap",
|
|
7
|
+
chunkIndex: Number(sitemapName),
|
|
8
|
+
chunkSize: defaultChunkSize
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
if (sitemapName.includes("-")) {
|
|
12
|
+
const parts = sitemapName.split("-");
|
|
13
|
+
const lastPart = parts.pop();
|
|
14
|
+
if (!Number.isNaN(Number(lastPart))) {
|
|
15
|
+
const baseSitemapName = parts.join("-");
|
|
16
|
+
const baseSitemap = sitemaps[baseSitemapName];
|
|
17
|
+
if (baseSitemap && (baseSitemap.chunks || baseSitemap._isChunking)) {
|
|
18
|
+
const chunkSize = typeof baseSitemap.chunks === "number" ? baseSitemap.chunks : baseSitemap.chunkSize || defaultChunkSize;
|
|
19
|
+
return {
|
|
20
|
+
isChunked: true,
|
|
21
|
+
baseSitemapName,
|
|
22
|
+
chunkIndex: Number(lastPart),
|
|
23
|
+
chunkSize
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
isChunked: false,
|
|
30
|
+
baseSitemapName: sitemapName,
|
|
31
|
+
chunkIndex: void 0,
|
|
32
|
+
chunkSize: defaultChunkSize
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export function getSitemapConfig(sitemapName, sitemaps, defaultChunkSize = 1e3) {
|
|
36
|
+
const chunkInfo = parseChunkInfo(sitemapName, sitemaps, defaultChunkSize);
|
|
37
|
+
if (chunkInfo.isChunked) {
|
|
38
|
+
if (chunkInfo.baseSitemapName === "sitemap" && typeof sitemaps.chunks !== "undefined") {
|
|
39
|
+
return {
|
|
40
|
+
...sitemaps.chunks,
|
|
41
|
+
sitemapName,
|
|
42
|
+
_isChunking: true,
|
|
43
|
+
_chunkSize: chunkInfo.chunkSize
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const baseSitemap = sitemaps[chunkInfo.baseSitemapName];
|
|
47
|
+
if (baseSitemap) {
|
|
48
|
+
return {
|
|
49
|
+
...baseSitemap,
|
|
50
|
+
sitemapName,
|
|
51
|
+
// Use the full name with chunk index
|
|
52
|
+
_isChunking: true,
|
|
53
|
+
_chunkSize: chunkInfo.chunkSize
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return sitemaps[sitemapName];
|
|
58
|
+
}
|
|
59
|
+
export function sliceUrlsForChunk(urls, sitemapName, sitemaps, defaultChunkSize = 1e3) {
|
|
60
|
+
const chunkInfo = parseChunkInfo(sitemapName, sitemaps, defaultChunkSize);
|
|
61
|
+
if (chunkInfo.isChunked && chunkInfo.chunkIndex !== void 0) {
|
|
62
|
+
const startIndex = chunkInfo.chunkIndex * chunkInfo.chunkSize;
|
|
63
|
+
const endIndex = (chunkInfo.chunkIndex + 1) * chunkInfo.chunkSize;
|
|
64
|
+
return urls.slice(startIndex, endIndex);
|
|
65
|
+
}
|
|
66
|
+
return urls;
|
|
67
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useRuntimeConfig } from "nitropack/runtime";
|
|
2
|
+
import { normalizeRuntimeFilters } from "../utils-pure.js";
|
|
3
|
+
export * from "../utils-pure.js";
|
|
4
|
+
export function xmlEscape(str) {
|
|
5
|
+
return String(str).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
6
|
+
}
|
|
7
|
+
export function useSitemapRuntimeConfig(e) {
|
|
8
|
+
const clone = JSON.parse(JSON.stringify(useRuntimeConfig(e).sitemap));
|
|
9
|
+
for (const k in clone.sitemaps) {
|
|
10
|
+
const sitemap = clone.sitemaps[k];
|
|
11
|
+
sitemap.include = normalizeRuntimeFilters(sitemap.include);
|
|
12
|
+
sitemap.exclude = normalizeRuntimeFilters(sitemap.exclude);
|
|
13
|
+
clone.sitemaps[k] = sitemap;
|
|
14
|
+
}
|
|
15
|
+
return Object.freeze(clone);
|
|
16
|
+
}
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import type { FetchOptions } from 'ofetch';
|
|
2
|
+
import type { H3Event } from 'h3';
|
|
3
|
+
import type { ParsedURL } from 'ufo';
|
|
4
|
+
import type { NuxtI18nOptions } from '@nuxtjs/i18n';
|
|
5
|
+
export interface ModuleOptions extends SitemapDefinition {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the sitemap.xml should be generated.
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Enables debug logs and a debug endpoint.
|
|
14
|
+
*
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
debug: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Minify the sitemap xml
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
minify: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Should lastmod be automatically added to the sitemap.
|
|
26
|
+
*
|
|
27
|
+
* Warning: This may not be following best practices for sitemaps.
|
|
28
|
+
*
|
|
29
|
+
* @see https://nuxtseo.com/sitemap/guides/best-practices.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
autoLastmod: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Sources to exclude from the sitemap.
|
|
35
|
+
*/
|
|
36
|
+
excludeAppSources: true | (AppSourceContext[]);
|
|
37
|
+
/**
|
|
38
|
+
* Multiple sitemap support for large sites.
|
|
39
|
+
*
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
sitemaps?: boolean | MultiSitemapsInput;
|
|
43
|
+
/**
|
|
44
|
+
* The path prefix for the sitemaps.
|
|
45
|
+
*
|
|
46
|
+
* @default /__sitemap__/
|
|
47
|
+
*/
|
|
48
|
+
sitemapsPathPrefix: string | false;
|
|
49
|
+
/**
|
|
50
|
+
* Sitemaps to append to the sitemap index.
|
|
51
|
+
*
|
|
52
|
+
* This will only do anything when using multiple sitemaps.
|
|
53
|
+
*/
|
|
54
|
+
appendSitemaps?: (string | SitemapIndexEntry)[];
|
|
55
|
+
/**
|
|
56
|
+
* Path to the xsl that styles sitemap.xml.
|
|
57
|
+
*
|
|
58
|
+
* Set to `false` to disable styling.
|
|
59
|
+
*
|
|
60
|
+
* @default /__sitemap__/style.xsl
|
|
61
|
+
*/
|
|
62
|
+
xsl: string | false;
|
|
63
|
+
/**
|
|
64
|
+
* Toggle the tips displayed in the xsl.
|
|
65
|
+
*
|
|
66
|
+
* @default true
|
|
67
|
+
*/
|
|
68
|
+
xslTips: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Customised the columns displayed in the xsl.
|
|
71
|
+
*
|
|
72
|
+
* @default [{ label: 'URL', width: '50%', select: 'string' }, { label: 'Last Modified', width: '25%', select: 'lastmod' }, { label: 'Change Frequency', width: '25%', select: 'changefreq' }]
|
|
73
|
+
*/
|
|
74
|
+
xslColumns?: {
|
|
75
|
+
label: string;
|
|
76
|
+
width: `${string}%`;
|
|
77
|
+
select?: string;
|
|
78
|
+
}[];
|
|
79
|
+
/**
|
|
80
|
+
* When prerendering, should images be automatically be discovered and added to the sitemap.
|
|
81
|
+
*
|
|
82
|
+
* @default true
|
|
83
|
+
*/
|
|
84
|
+
discoverImages: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* When prerendering, should videos be automatically be discovered and added to the sitemap.
|
|
87
|
+
*
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
discoverVideos: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* When chunking the sitemaps into multiple files, how many entries should each file contain.
|
|
93
|
+
*
|
|
94
|
+
* Set to `false` to disabling chunking completely.
|
|
95
|
+
*
|
|
96
|
+
* @default 1000
|
|
97
|
+
*/
|
|
98
|
+
defaultSitemapsChunkSize: number | false;
|
|
99
|
+
/**
|
|
100
|
+
* Modify the cache behavior.
|
|
101
|
+
*
|
|
102
|
+
* Passing a boolean will enable or disable the runtime cache with the default options.
|
|
103
|
+
*
|
|
104
|
+
* Providing a record will allow you to configure the runtime cache fully.
|
|
105
|
+
*
|
|
106
|
+
* @default true
|
|
107
|
+
* @see https://nitro.unjs.io/guide/storage#mountpoints
|
|
108
|
+
* @example { driver: 'redis', host: 'localhost', port: 6379, password: 'password' }
|
|
109
|
+
*/
|
|
110
|
+
runtimeCacheStorage: boolean | (Record<string, any> & {
|
|
111
|
+
driver: string;
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Automatically add alternative links to the sitemap based on a prefix list.
|
|
115
|
+
* Is used by @nuxtjs/i18n to automatically add alternative links to the sitemap.
|
|
116
|
+
*/
|
|
117
|
+
autoI18n?: boolean | AutoI18nConfig;
|
|
118
|
+
/**
|
|
119
|
+
* Enable when your nuxt/content files match your pages. This will automatically add sitemap content to the sitemap.
|
|
120
|
+
*
|
|
121
|
+
* This is similar behavior to using `nuxt/content` with `documentDriven: true`.
|
|
122
|
+
*/
|
|
123
|
+
strictNuxtContentPaths: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Should the sitemap.xml display credits for the module.
|
|
126
|
+
*
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
129
|
+
credits: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* How long, in seconds, should the sitemap be cached for.
|
|
132
|
+
*
|
|
133
|
+
* @default 600
|
|
134
|
+
*/
|
|
135
|
+
cacheMaxAgeSeconds: number | false;
|
|
136
|
+
/**
|
|
137
|
+
* Should the entries be sorted by loc.
|
|
138
|
+
*
|
|
139
|
+
* @default true
|
|
140
|
+
*/
|
|
141
|
+
sortEntries: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Warm up the sitemap route(s) cache when Nitro starts.
|
|
144
|
+
*
|
|
145
|
+
* May be implemented by default in a future minor version.
|
|
146
|
+
*
|
|
147
|
+
* @experimental Will be enabled by default in v5 (if stable)
|
|
148
|
+
*/
|
|
149
|
+
experimentalWarmUp?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Send the Sitemap as a compressed stream supporting gzip, brolti, etc.
|
|
152
|
+
*
|
|
153
|
+
* @experimental Will be enabled by default in v5 (if stable)
|
|
154
|
+
*/
|
|
155
|
+
experimentalCompression?: boolean;
|
|
156
|
+
}
|
|
157
|
+
export interface IndexSitemapRemotes {
|
|
158
|
+
index?: (string | SitemapIndexEntry)[];
|
|
159
|
+
}
|
|
160
|
+
export interface MultiSitemapEntry {
|
|
161
|
+
[key: string]: Partial<SitemapDefinition>;
|
|
162
|
+
}
|
|
163
|
+
export type MultiSitemapsInput = Partial<MultiSitemapEntry> & Partial<IndexSitemapRemotes>;
|
|
164
|
+
export type MaybeFunction<T> = T | (() => T);
|
|
165
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
166
|
+
export type SitemapUrlInput = SitemapUrl | string;
|
|
167
|
+
export interface SitemapSourceBase {
|
|
168
|
+
context: {
|
|
169
|
+
name: string;
|
|
170
|
+
description?: string;
|
|
171
|
+
tips?: string[];
|
|
172
|
+
};
|
|
173
|
+
fetch?: string | [string, FetchOptions];
|
|
174
|
+
urls?: SitemapUrlInput[];
|
|
175
|
+
sourceType?: 'app' | 'user';
|
|
176
|
+
}
|
|
177
|
+
export interface SitemapSourceResolved extends Omit<SitemapSourceBase, 'urls'> {
|
|
178
|
+
urls: SitemapUrlInput[];
|
|
179
|
+
error?: any;
|
|
180
|
+
timeTakenMs?: number;
|
|
181
|
+
_isFailure?: boolean;
|
|
182
|
+
}
|
|
183
|
+
export type AppSourceContext = 'nuxt:pages' | 'nuxt:prerender' | 'nuxt:route-rules' | '@nuxtjs/i18n:pages' | '@nuxt/content:document-driven';
|
|
184
|
+
export type SitemapSourceInput = string | [string, FetchOptions] | SitemapSourceBase | SitemapSourceResolved;
|
|
185
|
+
interface LocaleObject extends Record<string, any> {
|
|
186
|
+
code: string;
|
|
187
|
+
name?: string;
|
|
188
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
189
|
+
domain?: string;
|
|
190
|
+
domains?: string[];
|
|
191
|
+
defaultForDomains?: string[];
|
|
192
|
+
file?: string | {
|
|
193
|
+
path: string;
|
|
194
|
+
cache?: boolean;
|
|
195
|
+
};
|
|
196
|
+
files?: string[] | {
|
|
197
|
+
path: string;
|
|
198
|
+
cache?: boolean;
|
|
199
|
+
}[];
|
|
200
|
+
isCatchallLocale?: boolean;
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated in v9, use `language` instead
|
|
203
|
+
*/
|
|
204
|
+
iso?: string;
|
|
205
|
+
language?: string;
|
|
206
|
+
}
|
|
207
|
+
export interface AutoI18nConfig {
|
|
208
|
+
differentDomains?: boolean;
|
|
209
|
+
locales: (LocaleObject & {
|
|
210
|
+
_sitemap: string;
|
|
211
|
+
_hreflang: string;
|
|
212
|
+
})[];
|
|
213
|
+
defaultLocale: string;
|
|
214
|
+
strategy: 'prefix' | 'prefix_except_default' | 'prefix_and_default' | 'no_prefix';
|
|
215
|
+
pages?: Record<string, Record<string, string | false>>;
|
|
216
|
+
}
|
|
217
|
+
export interface ModuleRuntimeConfig extends Pick<ModuleOptions, 'sitemapsPathPrefix' | 'cacheMaxAgeSeconds' | 'sitemapName' | 'excludeAppSources' | 'sortEntries' | 'defaultSitemapsChunkSize' | 'xslColumns' | 'xslTips' | 'debug' | 'discoverImages' | 'discoverVideos' | 'autoLastmod' | 'xsl' | 'credits' | 'minify'> {
|
|
218
|
+
version: string;
|
|
219
|
+
isNuxtContentDocumentDriven: boolean;
|
|
220
|
+
sitemaps: {
|
|
221
|
+
index?: Pick<SitemapDefinition, 'sitemapName' | '_route'> & {
|
|
222
|
+
sitemaps: SitemapIndexEntry[];
|
|
223
|
+
};
|
|
224
|
+
} & Record<string, Omit<SitemapDefinition, 'urls'> & {
|
|
225
|
+
_hasSourceChunk?: boolean;
|
|
226
|
+
}>;
|
|
227
|
+
autoI18n?: AutoI18nConfig;
|
|
228
|
+
isMultiSitemap: boolean;
|
|
229
|
+
isI18nMapped: boolean;
|
|
230
|
+
}
|
|
231
|
+
export interface SitemapIndexEntry {
|
|
232
|
+
sitemap: string;
|
|
233
|
+
lastmod?: string;
|
|
234
|
+
/**
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
_sitemapName?: string;
|
|
238
|
+
}
|
|
239
|
+
export type FilterInput = (string | RegExp | {
|
|
240
|
+
regex: string;
|
|
241
|
+
});
|
|
242
|
+
export type ResolvedSitemapUrl = Omit<SitemapUrl, 'url'> & Required<Pick<SitemapUrl, 'loc'>> & {
|
|
243
|
+
/**
|
|
244
|
+
* @internal
|
|
245
|
+
*/
|
|
246
|
+
_key: string;
|
|
247
|
+
/**
|
|
248
|
+
* @internal
|
|
249
|
+
*/
|
|
250
|
+
_path: ParsedURL;
|
|
251
|
+
/**
|
|
252
|
+
* @internal
|
|
253
|
+
*/
|
|
254
|
+
_relativeLoc: string;
|
|
255
|
+
/**
|
|
256
|
+
* @internal
|
|
257
|
+
*/
|
|
258
|
+
_abs: boolean;
|
|
259
|
+
};
|
|
260
|
+
export interface SitemapDefinition {
|
|
261
|
+
/**
|
|
262
|
+
* A collection include patterns for filtering which URLs end up in the sitemap.
|
|
263
|
+
*/
|
|
264
|
+
include?: FilterInput[];
|
|
265
|
+
/**
|
|
266
|
+
* A collection exclude patterns for filtering which URLs end up in the sitemap.
|
|
267
|
+
*/
|
|
268
|
+
exclude?: FilterInput[];
|
|
269
|
+
/**
|
|
270
|
+
* Should the sitemap be generated using global sources.
|
|
271
|
+
*
|
|
272
|
+
* This is enabled by default when using a single sitemap. Otherwise, it will be opt-in.
|
|
273
|
+
*/
|
|
274
|
+
includeAppSources?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* The root sitemap name.
|
|
277
|
+
* Only works when multiple sitemaps option `sitemaps` isn't used.
|
|
278
|
+
*
|
|
279
|
+
* @default `sitemap.xml`
|
|
280
|
+
*/
|
|
281
|
+
sitemapName: string;
|
|
282
|
+
/**
|
|
283
|
+
* A resolvable collection of URLs to include in the sitemap.
|
|
284
|
+
*
|
|
285
|
+
* Will be resolved when the sitemap is generated.
|
|
286
|
+
*/
|
|
287
|
+
urls?: MaybeFunction<MaybePromise<SitemapUrlInput[]>>;
|
|
288
|
+
/**
|
|
289
|
+
* Default options for all URLs in the sitemap.
|
|
290
|
+
*/
|
|
291
|
+
defaults?: Omit<SitemapUrl, 'loc'>;
|
|
292
|
+
/**
|
|
293
|
+
* Additional sources of URLs to include in the sitemap.
|
|
294
|
+
*/
|
|
295
|
+
sources?: SitemapSourceInput[];
|
|
296
|
+
/**
|
|
297
|
+
* Whether to enable chunking for this sitemap.
|
|
298
|
+
*
|
|
299
|
+
* - `true`: Enable with default chunk size from `defaultSitemapsChunkSize`
|
|
300
|
+
* - `number`: Enable with specific chunk size (must be > 0)
|
|
301
|
+
* - `false` or `undefined`: Disable chunking
|
|
302
|
+
*
|
|
303
|
+
* Note: Chunking only applies to sitemaps with sources. URLs provided directly
|
|
304
|
+
* are not chunked.
|
|
305
|
+
*
|
|
306
|
+
* @default false
|
|
307
|
+
* @example true
|
|
308
|
+
* @example 5000
|
|
309
|
+
*/
|
|
310
|
+
chunks?: boolean | number;
|
|
311
|
+
/**
|
|
312
|
+
* The maximum number of URLs per chunk when chunking is enabled.
|
|
313
|
+
* Takes precedence over the `chunks` property when both are specified.
|
|
314
|
+
* Also overrides the global `defaultSitemapsChunkSize`.
|
|
315
|
+
*
|
|
316
|
+
* Must be a positive integer.
|
|
317
|
+
*
|
|
318
|
+
* @default 1000
|
|
319
|
+
* @example 500
|
|
320
|
+
* @example 10000
|
|
321
|
+
*/
|
|
322
|
+
chunkSize?: number;
|
|
323
|
+
/**
|
|
324
|
+
* @internal
|
|
325
|
+
*/
|
|
326
|
+
_route?: string;
|
|
327
|
+
/**
|
|
328
|
+
* @internal
|
|
329
|
+
*/
|
|
330
|
+
_isChunking?: boolean;
|
|
331
|
+
/**
|
|
332
|
+
* @internal
|
|
333
|
+
*/
|
|
334
|
+
_chunkSize?: number;
|
|
335
|
+
/**
|
|
336
|
+
* @internal
|
|
337
|
+
*/
|
|
338
|
+
_chunkCount?: number;
|
|
339
|
+
}
|
|
340
|
+
interface NitroBaseHook {
|
|
341
|
+
event: H3Event;
|
|
342
|
+
}
|
|
343
|
+
export interface SitemapIndexRenderCtx extends NitroBaseHook {
|
|
344
|
+
sitemaps: SitemapIndexEntry[];
|
|
345
|
+
}
|
|
346
|
+
export interface SitemapRenderCtx extends NitroBaseHook {
|
|
347
|
+
sitemapName: string;
|
|
348
|
+
urls: ResolvedSitemapUrl[];
|
|
349
|
+
}
|
|
350
|
+
export interface SitemapInputCtx extends NitroBaseHook {
|
|
351
|
+
sitemapName: string;
|
|
352
|
+
urls: SitemapUrlInput[];
|
|
353
|
+
}
|
|
354
|
+
export interface SitemapOutputHookCtx extends NitroBaseHook {
|
|
355
|
+
sitemapName: string;
|
|
356
|
+
sitemap: string;
|
|
357
|
+
}
|
|
358
|
+
export interface SitemapSourcesHookCtx extends NitroBaseHook {
|
|
359
|
+
sitemapName: string;
|
|
360
|
+
sources: (SitemapSourceBase | SitemapSourceResolved)[];
|
|
361
|
+
}
|
|
362
|
+
export type Changefreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
363
|
+
export interface SitemapUrl {
|
|
364
|
+
loc: string;
|
|
365
|
+
lastmod?: string | Date;
|
|
366
|
+
changefreq?: Changefreq;
|
|
367
|
+
priority?: 0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1;
|
|
368
|
+
alternatives?: Array<AlternativeEntry>;
|
|
369
|
+
news?: GoogleNewsEntry;
|
|
370
|
+
images?: Array<ImageEntry>;
|
|
371
|
+
videos?: Array<VideoEntry>;
|
|
372
|
+
_i18nTransform?: boolean;
|
|
373
|
+
_sitemap?: string | false;
|
|
374
|
+
}
|
|
375
|
+
export type SitemapStrict = Required<SitemapUrl>;
|
|
376
|
+
export interface AlternativeEntry {
|
|
377
|
+
hreflang: string;
|
|
378
|
+
href: string | URL;
|
|
379
|
+
}
|
|
380
|
+
export interface GoogleNewsEntry {
|
|
381
|
+
/**
|
|
382
|
+
* The title of the news article.
|
|
383
|
+
* @example "Companies A, B in Merger Talks"
|
|
384
|
+
*/
|
|
385
|
+
title: string;
|
|
386
|
+
/**
|
|
387
|
+
* The article publication date in W3C format. Specify the original date and time when the article was first
|
|
388
|
+
* published on your site. Don't specify the time when you added the article to your sitemap.
|
|
389
|
+
* @example "2008-12-23"
|
|
390
|
+
*/
|
|
391
|
+
publication_date: Date | string;
|
|
392
|
+
publication: {
|
|
393
|
+
/**
|
|
394
|
+
* The <news:name> tag is the name of the news publication.
|
|
395
|
+
* It must exactly match the name as it appears on your articles on news.google.com, omitting anything in parentheses.
|
|
396
|
+
* @example "The Example Times"
|
|
397
|
+
*/
|
|
398
|
+
name: string;
|
|
399
|
+
/**
|
|
400
|
+
* The <news:language> tag is the language of your publication. Use an ISO 639 language code (two or three letters).
|
|
401
|
+
* @example en
|
|
402
|
+
*/
|
|
403
|
+
language: string;
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
export interface ImageEntry {
|
|
407
|
+
loc: string | URL;
|
|
408
|
+
caption?: string;
|
|
409
|
+
geoLocation?: string;
|
|
410
|
+
title?: string;
|
|
411
|
+
license?: string | URL;
|
|
412
|
+
}
|
|
413
|
+
export interface VideoEntry {
|
|
414
|
+
title: string;
|
|
415
|
+
thumbnail_loc: string | URL;
|
|
416
|
+
description: string;
|
|
417
|
+
content_loc?: string | URL;
|
|
418
|
+
player_loc?: string | URL;
|
|
419
|
+
duration?: number;
|
|
420
|
+
expiration_date?: Date | string;
|
|
421
|
+
rating?: number;
|
|
422
|
+
view_count?: number;
|
|
423
|
+
publication_date?: Date | string;
|
|
424
|
+
family_friendly?: 'yes' | 'no' | boolean;
|
|
425
|
+
restriction?: Restriction;
|
|
426
|
+
platform?: Platform;
|
|
427
|
+
price?: ({
|
|
428
|
+
price?: number | string;
|
|
429
|
+
currency?: string;
|
|
430
|
+
type?: 'rent' | 'purchase' | 'package' | 'subscription';
|
|
431
|
+
})[];
|
|
432
|
+
requires_subscription?: 'yes' | 'no' | boolean;
|
|
433
|
+
uploader?: {
|
|
434
|
+
uploader: string;
|
|
435
|
+
info?: string | URL;
|
|
436
|
+
};
|
|
437
|
+
live?: 'yes' | 'no' | boolean;
|
|
438
|
+
tag?: string | string[];
|
|
439
|
+
}
|
|
440
|
+
export interface Restriction {
|
|
441
|
+
relationship: 'allow' | 'deny';
|
|
442
|
+
restriction: string;
|
|
443
|
+
}
|
|
444
|
+
export interface Platform {
|
|
445
|
+
relationship: 'allow' | 'deny';
|
|
446
|
+
platform: string;
|
|
447
|
+
}
|
|
448
|
+
export interface NitroUrlResolvers {
|
|
449
|
+
event: H3Event;
|
|
450
|
+
canonicalUrlResolver: (path: string) => string;
|
|
451
|
+
relativeBaseUrlResolver: (path: string) => string;
|
|
452
|
+
fixSlashes: (path: string) => string;
|
|
453
|
+
}
|
|
454
|
+
interface NuxtI18nMicro {
|
|
455
|
+
includeDefaultLocaleRoute?: boolean;
|
|
456
|
+
}
|
|
457
|
+
export type I18nIntegrationOptions = NuxtI18nOptions & NuxtI18nMicro;
|
|
458
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FilterInput } from './types.js';
|
|
2
|
+
export declare const logger: import("consola").ConsolaInstance;
|
|
3
|
+
export declare function mergeOnKey<T, K extends keyof T>(arr: T[], key: K): T[];
|
|
4
|
+
export declare function splitForLocales(path: string, locales: string[]): [string | null, string];
|
|
5
|
+
/**
|
|
6
|
+
* Transform a literal notation string regex to RegExp
|
|
7
|
+
*/
|
|
8
|
+
export declare function normalizeRuntimeFilters(input?: FilterInput[]): (RegExp | string)[];
|
|
9
|
+
export interface CreateFilterOptions {
|
|
10
|
+
include?: (FilterInput | string | RegExp)[];
|
|
11
|
+
exclude?: (FilterInput | string | RegExp)[];
|
|
12
|
+
}
|
|
13
|
+
export declare function createPathFilter(options?: CreateFilterOptions): (loc: string) => boolean;
|
|
14
|
+
export declare function createFilter(options?: CreateFilterOptions): (path: string) => boolean;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { createDefu } from "defu";
|
|
2
|
+
import { parseURL, withLeadingSlash } from "ufo";
|
|
3
|
+
import { createRouter, toRouteMatcher } from "radix3";
|
|
4
|
+
import { createConsola } from "consola";
|
|
5
|
+
export const logger = createConsola({
|
|
6
|
+
defaults: {
|
|
7
|
+
tag: "@nuxt/sitemap"
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
const merger = createDefu((obj, key, value) => {
|
|
11
|
+
if (Array.isArray(obj[key]) && Array.isArray(value))
|
|
12
|
+
obj[key] = Array.from(/* @__PURE__ */ new Set([...obj[key], ...value]));
|
|
13
|
+
return obj[key];
|
|
14
|
+
});
|
|
15
|
+
export function mergeOnKey(arr, key) {
|
|
16
|
+
const seen = /* @__PURE__ */ new Map();
|
|
17
|
+
let resultLength = 0;
|
|
18
|
+
const result = Array.from({ length: arr.length });
|
|
19
|
+
for (const item of arr) {
|
|
20
|
+
const k = item[key];
|
|
21
|
+
if (seen.has(k)) {
|
|
22
|
+
const existingIndex = seen.get(k);
|
|
23
|
+
result[existingIndex] = merger(item, result[existingIndex]);
|
|
24
|
+
} else {
|
|
25
|
+
seen.set(k, resultLength);
|
|
26
|
+
result[resultLength++] = item;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result.slice(0, resultLength);
|
|
30
|
+
}
|
|
31
|
+
export function splitForLocales(path, locales) {
|
|
32
|
+
const prefix = withLeadingSlash(path).split("/")[1];
|
|
33
|
+
if (locales.includes(prefix))
|
|
34
|
+
return [prefix, path.replace(`/${prefix}`, "")];
|
|
35
|
+
return [null, path];
|
|
36
|
+
}
|
|
37
|
+
const StringifiedRegExpPattern = /\/(.*?)\/([gimsuy]*)$/;
|
|
38
|
+
export function normalizeRuntimeFilters(input) {
|
|
39
|
+
return (input || []).map((rule) => {
|
|
40
|
+
if (rule instanceof RegExp || typeof rule === "string")
|
|
41
|
+
return rule;
|
|
42
|
+
const match = rule.regex.match(StringifiedRegExpPattern);
|
|
43
|
+
if (match)
|
|
44
|
+
return new RegExp(match[1], match[2]);
|
|
45
|
+
return false;
|
|
46
|
+
}).filter(Boolean);
|
|
47
|
+
}
|
|
48
|
+
export function createPathFilter(options = {}) {
|
|
49
|
+
const urlFilter = createFilter(options);
|
|
50
|
+
return (loc) => {
|
|
51
|
+
let path = loc;
|
|
52
|
+
try {
|
|
53
|
+
path = parseURL(loc).pathname;
|
|
54
|
+
} catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return urlFilter(path);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export function createFilter(options = {}) {
|
|
61
|
+
const include = options.include || [];
|
|
62
|
+
const exclude = options.exclude || [];
|
|
63
|
+
if (include.length === 0 && exclude.length === 0)
|
|
64
|
+
return () => true;
|
|
65
|
+
return function(path) {
|
|
66
|
+
for (const v of [{ rules: exclude, result: false }, { rules: include, result: true }]) {
|
|
67
|
+
const regexRules = v.rules.filter((r) => r instanceof RegExp);
|
|
68
|
+
if (regexRules.some((r) => r.test(path)))
|
|
69
|
+
return v.result;
|
|
70
|
+
const stringRules = v.rules.filter((r) => typeof r === "string");
|
|
71
|
+
if (stringRules.length > 0) {
|
|
72
|
+
const routes = {};
|
|
73
|
+
for (const r of stringRules) {
|
|
74
|
+
if (r === path)
|
|
75
|
+
return v.result;
|
|
76
|
+
routes[r] = true;
|
|
77
|
+
}
|
|
78
|
+
const routeRulesMatcher = toRouteMatcher(createRouter({ routes, strictTrailingSlash: false }));
|
|
79
|
+
if (routeRulesMatcher.matchAll(path).length > 0)
|
|
80
|
+
return Boolean(v.result);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return include.length === 0;
|
|
84
|
+
};
|
|
85
|
+
}
|