@nuxtjs/sitemap 8.3.1 → 8.3.3
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/dist/module.json +1 -1
- package/dist/module.mjs +20 -41
- package/dist/runtime/server/composables/defineSitemapEventHandler.d.ts +2 -2
- package/dist/runtime/server/composables/defineSitemapEventHandler.js +1 -1
- package/dist/runtime/server/plugins/compression.d.ts +1 -1
- package/dist/runtime/server/plugins/compression.js +2 -2
- package/dist/runtime/server/plugins/nuxt-content-v2.d.ts +1 -1
- package/dist/runtime/server/plugins/nuxt-content-v2.js +1 -1
- package/dist/runtime/server/plugins/stream-transport.d.ts +1 -1
- package/dist/runtime/server/plugins/stream-transport.js +2 -2
- package/dist/runtime/server/plugins/warm-up.d.ts +1 -1
- package/dist/runtime/server/plugins/warm-up.js +1 -1
- package/dist/runtime/server/robots-polyfill/getPathRobotConfig.d.ts +1 -1
- package/dist/runtime/server/routes/__sitemap__/debug-production.d.ts +1 -1
- package/dist/runtime/server/routes/__sitemap__/debug-production.js +1 -1
- package/dist/runtime/server/routes/__sitemap__/debug.d.ts +1 -46
- package/dist/runtime/server/routes/__sitemap__/debug.js +1 -1
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.d.ts +1 -1
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v2.js +1 -1
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.d.ts +1 -1
- package/dist/runtime/server/routes/__sitemap__/nuxt-content-urls-v3.js +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.d.ts +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap/[sitemap].xml.js +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.d.ts +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap.xml.js +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.d.ts +1 -1
- package/dist/runtime/server/routes/__zero-runtime/sitemap_index.xml.js +1 -1
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap/[sitemap].xml.js +1 -1
- package/dist/runtime/server/routes/sitemap.xml.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.xml.js +1 -1
- package/dist/runtime/server/routes/sitemap.xsl.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap.xsl.js +1 -1
- package/dist/runtime/server/routes/sitemap_index.xml.d.ts +1 -1
- package/dist/runtime/server/routes/sitemap_index.xml.js +1 -1
- package/dist/runtime/server/sitemap/builder/sitemap-index.d.ts +3 -9
- package/dist/runtime/server/sitemap/builder/sitemap-index.js +2 -2
- package/dist/runtime/server/sitemap/builder/sitemap.d.ts +2 -3
- package/dist/runtime/server/sitemap/builder/sitemap.js +2 -2
- package/dist/runtime/server/sitemap/event-handlers.d.ts +2 -2
- package/dist/runtime/server/sitemap/event-handlers.js +2 -2
- package/dist/runtime/server/sitemap/nitro.d.ts +4 -2
- package/dist/runtime/server/sitemap/nitro.js +2 -2
- package/dist/runtime/server/sitemap/urlset/sources.d.ts +1 -1
- package/dist/runtime/server/sitemap/urlset/sources.js +5 -4
- package/dist/runtime/server/utils.d.ts +1 -1
- package/dist/runtime/server/utils.js +1 -1
- package/dist/runtime/types.d.ts +7 -7
- package/dist/utils.d.mts +94 -3
- package/dist/utils.d.ts +94 -3
- package/dist/utils.mjs +235 -1
- package/package.json +13 -12
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { useNuxt, hasNuxtModule, addTypeTemplate, addTemplate, defineNuxtModule,
|
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { withSiteUrl, installNuxtSiteConfig } from 'nuxt-site-config/kit';
|
|
4
4
|
import { isPathFile } from 'nuxt-site-config/urls';
|
|
5
|
-
import { isNuxtGenerate, useModuleLogger, getNuxtModuleOptions, resolveNitroPreset, resolveNuxtContentVersion, createPagesPromise, createNitroPromise } from 'nuxtseo-shared/kit';
|
|
5
|
+
import { isNuxtGenerate, renderNitroTypeAugmentations, useModuleLogger, setupNitroRuntimeCompatibility, getNuxtModuleOptions, resolveNitroPreset, resolveNuxtContentVersion, createPagesPromise, createNitroPromise } from 'nuxtseo-shared/kit';
|
|
6
6
|
import { serializeFilters } from 'nuxtseo-shared/utils';
|
|
7
7
|
import { dirname, extname } from 'pathe';
|
|
8
8
|
import { readPackageJSON } from 'pkg-types';
|
|
@@ -174,53 +174,31 @@ async function prerenderRoute(nitro, route) {
|
|
|
174
174
|
return { filePath, prerenderUrls };
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function registerTypeTemplates() {
|
|
177
|
+
function registerTypeTemplates(nitroCompatibility) {
|
|
178
178
|
const hasRobotsModule = hasNuxtModule("@nuxtjs/robots") || hasNuxtModule("nuxt-simple-robots");
|
|
179
179
|
addTypeTemplate({
|
|
180
180
|
filename: "types/nuxt-sitemap-augments.d.ts",
|
|
181
181
|
getContents: () => {
|
|
182
|
-
const robotsType = hasRobotsModule ? "" : "
|
|
182
|
+
const robotsType = hasRobotsModule ? "" : "robots?: boolean\n";
|
|
183
|
+
const routeRules = `${robotsType}sitemap?: SitemapItemDefaults | false`;
|
|
184
|
+
const runtimeHooks = `'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
|
|
185
|
+
'sitemap:input': (ctx: SitemapInputCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
|
|
186
|
+
'sitemap:resolved': (ctx: SitemapRenderCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
|
|
187
|
+
'sitemap:output': (ctx: SitemapOutputHookCtx<${nitroCompatibility.eventType}>) => void | Promise<void>
|
|
188
|
+
'sitemap:sources': (ctx: SitemapSourcesHookCtx<${nitroCompatibility.eventType}>) => void | Promise<void>`;
|
|
189
|
+
const nitroTypes = renderNitroTypeAugmentations(nitroCompatibility, {
|
|
190
|
+
nitroInterfaces: {
|
|
191
|
+
PrerenderRoute: "_sitemap?: SitemapUrl"
|
|
192
|
+
},
|
|
193
|
+
routeConfig: routeRules,
|
|
194
|
+
routeRules,
|
|
195
|
+
runtimeHooks
|
|
196
|
+
});
|
|
183
197
|
return `// Generated by @nuxtjs/sitemap
|
|
184
198
|
/// <reference path="./nuxt-sitemap-virtual.d.ts" />
|
|
185
199
|
import type { SitemapUrl, SitemapItemDefaults, SitemapIndexRenderCtx, SitemapInputCtx, SitemapRenderCtx, SitemapOutputHookCtx, SitemapSourcesHookCtx } from '@nuxtjs/sitemap'
|
|
186
200
|
|
|
187
|
-
|
|
188
|
-
interface PrerenderRoute {
|
|
189
|
-
_sitemap?: SitemapUrl
|
|
190
|
-
}
|
|
191
|
-
interface NitroRouteRules {
|
|
192
|
-
${robotsType} sitemap?: SitemapItemDefaults | false
|
|
193
|
-
}
|
|
194
|
-
interface NitroRouteConfig {
|
|
195
|
-
${robotsType} sitemap?: SitemapItemDefaults | false
|
|
196
|
-
}
|
|
197
|
-
interface NitroRuntimeHooks {
|
|
198
|
-
'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
|
|
199
|
-
'sitemap:input': (ctx: SitemapInputCtx) => void | Promise<void>
|
|
200
|
-
'sitemap:resolved': (ctx: SitemapRenderCtx) => void | Promise<void>
|
|
201
|
-
'sitemap:output': (ctx: SitemapOutputHookCtx) => void | Promise<void>
|
|
202
|
-
'sitemap:sources': (ctx: SitemapSourcesHookCtx) => void | Promise<void>
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
declare module 'nitropack/types' {
|
|
207
|
-
interface PrerenderRoute {
|
|
208
|
-
_sitemap?: SitemapUrl
|
|
209
|
-
}
|
|
210
|
-
interface NitroRouteRules {
|
|
211
|
-
${robotsType} sitemap?: SitemapItemDefaults | false
|
|
212
|
-
}
|
|
213
|
-
interface NitroRouteConfig {
|
|
214
|
-
${robotsType} sitemap?: SitemapItemDefaults | false
|
|
215
|
-
}
|
|
216
|
-
interface NitroRuntimeHooks {
|
|
217
|
-
'sitemap:index-resolved': (ctx: SitemapIndexRenderCtx) => void | Promise<void>
|
|
218
|
-
'sitemap:input': (ctx: SitemapInputCtx) => void | Promise<void>
|
|
219
|
-
'sitemap:resolved': (ctx: SitemapRenderCtx) => void | Promise<void>
|
|
220
|
-
'sitemap:output': (ctx: SitemapOutputHookCtx) => void | Promise<void>
|
|
221
|
-
'sitemap:sources': (ctx: SitemapSourcesHookCtx) => void | Promise<void>
|
|
222
|
-
}
|
|
223
|
-
}
|
|
201
|
+
${nitroTypes}
|
|
224
202
|
|
|
225
203
|
declare module 'vue-router' {
|
|
226
204
|
interface RouteMeta {
|
|
@@ -518,6 +496,7 @@ const module$1 = defineNuxtModule({
|
|
|
518
496
|
logger.debug("The module is disabled, skipping setup.");
|
|
519
497
|
return;
|
|
520
498
|
}
|
|
499
|
+
const nitroCompatibility = setupNitroRuntimeCompatibility(nuxt);
|
|
521
500
|
config.exclude.push(`${withTrailingSlash(nuxt.options.app.buildAssetsDir)}**`);
|
|
522
501
|
nuxt.options.alias["#sitemap"] = resolve("./runtime");
|
|
523
502
|
nuxt.options.nitro.alias = nuxt.options.nitro.alias || {};
|
|
@@ -709,7 +688,7 @@ const module$1 = defineNuxtModule({
|
|
|
709
688
|
}]);
|
|
710
689
|
}
|
|
711
690
|
});
|
|
712
|
-
registerTypeTemplates();
|
|
691
|
+
registerTypeTemplates(nitroCompatibility);
|
|
713
692
|
const prerenderedRoutes = nuxt.options.nitro.prerender?.routes || [];
|
|
714
693
|
let prerenderSitemap = isNuxtGenerate() || includesSitemapRoot(config.sitemapName, prerenderedRoutes);
|
|
715
694
|
if (resolveNitroPreset() === "vercel-edge") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventHandlerRequest, EventHandlerResponse } from 'h3';
|
|
1
|
+
import type { EventHandlerRequest, EventHandlerResponse } from '#nuxtseo/h3';
|
|
2
2
|
import type { SitemapUrlInput } from '../../types.js';
|
|
3
|
-
import { defineEventHandler } from 'h3';
|
|
3
|
+
import { defineEventHandler } from '#nuxtseo/h3';
|
|
4
4
|
export declare const defineSitemapEventHandler: typeof defineEventHandler<EventHandlerRequest, EventHandlerResponse<SitemapUrlInput[]>>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
1
|
+
import { defineEventHandler } from "#nuxtseo/h3";
|
|
2
2
|
export const defineSitemapEventHandler = defineEventHandler;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { appendResponseHeader, getRequestHeader, getResponseHeader, removeResponseHeader, setResponseHeader } from "h3";
|
|
2
|
-
import { defineNitroPlugin } from "
|
|
1
|
+
import { appendResponseHeader, getRequestHeader, getResponseHeader, removeResponseHeader, setResponseHeader } from "#nuxtseo/h3";
|
|
2
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
3
3
|
import { logger } from "../../utils-pure.js";
|
|
4
4
|
import { hasNonIdentityEncoding, isReadableStream, negotiateCompressionEncoding } from "../sitemap/stream.js";
|
|
5
5
|
let warnedAboutCompressionStream = false;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import { defineNitroPlugin } from "
|
|
2
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
3
3
|
import { useSitemapRuntimeConfig } from "../utils.js";
|
|
4
4
|
export default defineNitroPlugin((nitroApp) => {
|
|
5
5
|
const { discoverImages, isNuxtContentDocumentDriven } = useSitemapRuntimeConfig();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { removeResponseHeader } from "h3";
|
|
2
|
-
import { defineNitroPlugin } from "
|
|
1
|
+
import { removeResponseHeader } from "#nuxtseo/h3";
|
|
2
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
3
3
|
import { logger } from "../../utils-pure.js";
|
|
4
4
|
import { createNodeResponseStream, isReadableStream } from "../sitemap/stream.js";
|
|
5
5
|
export default defineNitroPlugin((nitro) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineNitroPlugin } from "nitropack/runtime";
|
|
2
1
|
import { joinURL, withLeadingSlash } from "ufo";
|
|
2
|
+
import { defineNitroPlugin } from "#nuxtseo/nitro";
|
|
3
3
|
import { useSitemapRuntimeConfig } from "../utils.js";
|
|
4
4
|
export default defineNitroPlugin((nitroApp) => {
|
|
5
5
|
const { sitemaps, sitemapsPathPrefix } = useSitemapRuntimeConfig();
|
|
@@ -13,5 +13,5 @@ export interface ProductionDebugResponse {
|
|
|
13
13
|
warnings: SitemapIssue[];
|
|
14
14
|
error?: string;
|
|
15
15
|
}
|
|
16
|
-
declare const _default:
|
|
16
|
+
declare const _default: any;
|
|
17
17
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineEventHandler, getQuery } from "h3";
|
|
2
1
|
import { collectSitemap } from "sitemapd/parse";
|
|
2
|
+
import { defineEventHandler, getQuery } from "#nuxtseo/h3";
|
|
3
3
|
async function fetchSitemapBody(url) {
|
|
4
4
|
const response = await fetch(url, {
|
|
5
5
|
headers: { Accept: "application/xml, text/xml, application/gzip" },
|
|
@@ -1,47 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<{
|
|
3
|
-
nitroOrigin: string;
|
|
4
|
-
sitemaps: Record<string, SitemapDefinition>;
|
|
5
|
-
runtimeConfig: {
|
|
6
|
-
version: string;
|
|
7
|
-
isNuxtContentDocumentDriven: boolean;
|
|
8
|
-
sitemaps: {
|
|
9
|
-
index?: Pick<SitemapDefinition, "sitemapName" | "_route"> & {
|
|
10
|
-
sitemaps: import("../../../types.js").SitemapIndexEntry[];
|
|
11
|
-
};
|
|
12
|
-
} & Record<string, Omit<SitemapDefinition, "urls"> & {
|
|
13
|
-
_hasSourceChunk?: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
autoI18n?: import("../../../types.js").AutoI18nConfig;
|
|
16
|
-
hasDisabledAutoI18n?: boolean;
|
|
17
|
-
isMultiSitemap: boolean;
|
|
18
|
-
isI18nMapped: boolean;
|
|
19
|
-
sitemapsPathPrefix: string | false;
|
|
20
|
-
cacheMaxAgeSeconds: number | false;
|
|
21
|
-
sitemapName: string;
|
|
22
|
-
excludeAppSources: true | (import("../../../types.js").AppSourceContext[]);
|
|
23
|
-
sortEntries: boolean;
|
|
24
|
-
defaultSitemapsChunkSize: number | false;
|
|
25
|
-
xslColumns?: {
|
|
26
|
-
label: string;
|
|
27
|
-
width: `${string}%`;
|
|
28
|
-
select?: string;
|
|
29
|
-
}[] | undefined;
|
|
30
|
-
xslTips: boolean;
|
|
31
|
-
debug: boolean;
|
|
32
|
-
discoverImages: boolean;
|
|
33
|
-
discoverVideos: boolean;
|
|
34
|
-
autoLastmod: boolean;
|
|
35
|
-
xsl: string | false;
|
|
36
|
-
credits: boolean;
|
|
37
|
-
minify: boolean;
|
|
38
|
-
experimentalStreaming?: boolean | undefined;
|
|
39
|
-
};
|
|
40
|
-
globalSources: SitemapSourceResolved[];
|
|
41
|
-
siteConfig: {
|
|
42
|
-
[x: string]: any;
|
|
43
|
-
[x: number]: any;
|
|
44
|
-
url: string;
|
|
45
|
-
};
|
|
46
|
-
}>>;
|
|
1
|
+
declare const _default: any;
|
|
47
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineEventHandler } from "h3";
|
|
2
1
|
import { serverQueryContent } from "#content/server";
|
|
2
|
+
import { defineEventHandler } from "#nuxtseo/h3";
|
|
3
3
|
export default defineEventHandler(async (e) => {
|
|
4
4
|
const contentList = await serverQueryContent(e).find();
|
|
5
5
|
return contentList.map((c) => c.sitemap).filter(Boolean);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { queryCollection } from "@nuxt/content/server";
|
|
2
|
-
import { defineEventHandler } from "h3";
|
|
3
2
|
import manifest from "#content/manifest";
|
|
3
|
+
import { defineEventHandler } from "#nuxtseo/h3";
|
|
4
4
|
import { filters } from "#sitemap/content-filters";
|
|
5
5
|
import { onUrlFns } from "#sitemap/content-on-url";
|
|
6
6
|
export default defineEventHandler(async (e) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError, defineEventHandler } from "h3";
|
|
1
|
+
import { createError, defineEventHandler } from "#nuxtseo/h3";
|
|
2
2
|
export default defineEventHandler(async (e) => {
|
|
3
3
|
if (import.meta.dev || import.meta.prerender) {
|
|
4
4
|
const { sitemapChildXmlEventHandler } = await import("../../../sitemap/event-handlers.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError, defineEventHandler } from "h3";
|
|
1
|
+
import { createError, defineEventHandler } from "#nuxtseo/h3";
|
|
2
2
|
export default defineEventHandler(async (e) => {
|
|
3
3
|
if (import.meta.dev || import.meta.prerender) {
|
|
4
4
|
const { sitemapXmlEventHandler } = await import("../../sitemap/event-handlers.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createError, defineEventHandler } from "h3";
|
|
1
|
+
import { createError, defineEventHandler } from "#nuxtseo/h3";
|
|
2
2
|
export default defineEventHandler(async (e) => {
|
|
3
3
|
if (import.meta.dev || import.meta.prerender) {
|
|
4
4
|
const { sitemapIndexXmlEventHandler } = await import("../../sitemap/event-handlers.js");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineEventHandler, getHeader, getQuery as h3GetQuery, setHeader } from "h3";
|
|
2
1
|
import { getQuery, parseURL, withQuery } from "ufo";
|
|
2
|
+
import { defineEventHandler, getHeader, getQuery as h3GetQuery, setHeader } from "#nuxtseo/h3";
|
|
3
3
|
import { getSiteConfig } from "#site-config/server/composables";
|
|
4
4
|
import { createSitePathResolver } from "#site-config/server/composables/utils";
|
|
5
5
|
import { useSitemapRuntimeConfig, xmlEscape } from "../utils.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: any;
|
|
2
2
|
export default _default;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function buildSitemapIndex(resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<
|
|
4
|
-
entries: SitemapIndexEntry[];
|
|
5
|
-
failedSources: Array<{
|
|
6
|
-
url: string;
|
|
7
|
-
error: string;
|
|
8
|
-
}>;
|
|
9
|
-
}>;
|
|
1
|
+
import type { ModuleRuntimeConfig, NitroUrlResolvers } from '../../../types.js';
|
|
2
|
+
type NitroApp = ReturnType<typeof import('#nuxtseo/nitro').useNitroApp>;
|
|
3
|
+
export declare function buildSitemapIndex(resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<any>;
|
|
10
4
|
export { urlsToIndexXml, urlsToIndexXmlStream } from './index-xml.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getHeader } from "h3";
|
|
2
|
-
import { defineCachedFunction } from "nitropack/runtime";
|
|
3
1
|
import { joinURL } from "ufo";
|
|
2
|
+
import { getHeader } from "#nuxtseo/h3";
|
|
3
|
+
import { defineCachedFunction } from "#nuxtseo/nitro";
|
|
4
4
|
import staticConfig from "#sitemap-virtual/static-config.mjs";
|
|
5
5
|
import { normaliseDate } from "../urlset/normalise.js";
|
|
6
6
|
import { getResolvedSitemapUrls } from "./sitemap.js";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
import type { NitroApp } from 'nitropack/types';
|
|
3
1
|
import type { AutoI18nConfig, ModuleRuntimeConfig, NitroUrlResolvers, ResolvedSitemapUrl, SitemapDefinition, SitemapUrlInput } from '../../../types.js';
|
|
2
|
+
type NitroApp = ReturnType<typeof import('#nuxtseo/nitro').useNitroApp>;
|
|
4
3
|
export interface NormalizedI18n extends ResolvedSitemapUrl {
|
|
5
4
|
_pathWithoutPrefix: string;
|
|
6
5
|
_locale: AutoI18nConfig['locales'][number];
|
|
@@ -15,7 +14,7 @@ export interface ResolvedSitemapUrlsResult {
|
|
|
15
14
|
}>;
|
|
16
15
|
}
|
|
17
16
|
export declare function buildResolvedSitemapUrls(effectiveSitemap: SitemapDefinition, matchName: string, isChunked: boolean, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
|
|
18
|
-
export declare const buildResolvedSitemapUrlsCached:
|
|
17
|
+
export declare const buildResolvedSitemapUrlsCached: any;
|
|
19
18
|
export declare function getResolvedSitemapUrls(effectiveSitemap: SitemapDefinition, matchName: string, isChunked: boolean, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
|
|
20
19
|
export declare function buildSitemapUrls(sitemap: SitemapDefinition, resolvers: NitroUrlResolvers, runtimeConfig: ModuleRuntimeConfig, nitro?: NitroApp): Promise<ResolvedSitemapUrlsResult>;
|
|
21
20
|
export { urlsToXml, urlsToXmlStream } from './xml.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getHeader } from "h3";
|
|
2
|
-
import { defineCachedFunction, useRuntimeConfig } from "nitropack/runtime";
|
|
3
1
|
import { resolveSitePath } from "nuxt-site-config/urls";
|
|
4
2
|
import { joinURL, withHttps } from "ufo";
|
|
3
|
+
import { getHeader } from "#nuxtseo/h3";
|
|
4
|
+
import { defineCachedFunction, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
5
5
|
import staticConfig from "#sitemap-virtual/static-config.mjs";
|
|
6
6
|
import { applyDynamicParams, createPathFilter, findPageMapping, logger, resolveI18nSitemapLocaleKey, splitForLocales } from "../../../utils-pure.js";
|
|
7
7
|
import { preNormalizeEntry } from "../urlset/normalise.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
export declare function sitemapXmlEventHandler(e: H3Event): Promise<
|
|
1
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
2
|
+
export declare function sitemapXmlEventHandler(e: H3Event): Promise<any>;
|
|
3
3
|
export declare function sitemapIndexXmlEventHandler(e: H3Event): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
4
4
|
export declare function sitemapChildXmlEventHandler(e: H3Event): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>> | undefined>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { appendHeader, createError, getRequestURL, getRouterParam, sendRedirect } from "h3";
|
|
2
|
-
import { useNitroApp, useRuntimeConfig } from "nitropack/runtime";
|
|
3
1
|
import { joinURL, withBase, withLeadingSlash, withoutLeadingSlash, withoutTrailingSlash } from "ufo";
|
|
2
|
+
import { appendHeader, createError, getRequestURL, getRouterParam, sendRedirect } from "#nuxtseo/h3";
|
|
3
|
+
import { useNitroApp, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
4
4
|
import { useSitemapRuntimeConfig } from "../utils.js";
|
|
5
5
|
import { urlsToIndexXml, urlsToIndexXmlStream } from "./builder/index-xml.js";
|
|
6
6
|
import { buildSitemapIndex } from "./builder/sitemap-index.js";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
2
|
-
import type { NitroApp } from 'nitropack/types';
|
|
1
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
3
2
|
import type { ModuleRuntimeConfig, NitroUrlResolvers, SitemapDefinition } from '../../types.js';
|
|
3
|
+
import { useNitroApp } from '#nuxtseo/nitro';
|
|
4
|
+
type NitroApp = ReturnType<typeof useNitroApp>;
|
|
4
5
|
export declare function useNitroUrlResolvers(e: H3Event): NitroUrlResolvers;
|
|
5
6
|
export declare function renderSitemapOutput(nitro: NitroApp, event: H3Event, sitemapName: string, renderString: () => string, renderStream: () => ReadableStream<Uint8Array>, shouldStream: boolean, debug: boolean): Promise<string | ReadableStream<Uint8Array>>;
|
|
6
7
|
export declare function setSitemapResponseHeaders(event: H3Event, runtimeConfig: ModuleRuntimeConfig): void;
|
|
7
8
|
export declare function createSitemap(event: H3Event, definition: SitemapDefinition, runtimeConfig: ModuleRuntimeConfig): Promise<string | ReadableStream<Uint8Array<ArrayBufferLike>>>;
|
|
9
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import { createError, getHeader, getQuery, setHeader } from "h3";
|
|
3
|
-
import { defineCachedFunction, useNitroApp, useRuntimeConfig } from "nitropack/runtime";
|
|
4
2
|
import { fixSlashes } from "nuxt-site-config/urls";
|
|
5
3
|
import { createNitroRouteRuleMatcher } from "nuxtseo-shared/server";
|
|
6
4
|
import { getPathRobotConfig } from "#internal/nuxt-robots/getPathRobotConfig";
|
|
5
|
+
import { createError, getHeader, getQuery, setHeader } from "#nuxtseo/h3";
|
|
6
|
+
import { defineCachedFunction, useNitroApp, useRuntimeConfig } from "#nuxtseo/nitro";
|
|
7
7
|
import { getSiteConfig } from "#site-config/server/composables/getSiteConfig";
|
|
8
8
|
import { createSitePathResolver } from "#site-config/server/composables/utils";
|
|
9
9
|
import staticConfig from "#sitemap-virtual/static-config.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { H3Event } from 'h3';
|
|
1
|
+
import type { H3Event } from '#nuxtseo/h3';
|
|
2
2
|
import type { ModuleRuntimeConfig, SitemapSourceBase, SitemapSourceInput, SitemapSourceResolved } from '../../../types.js';
|
|
3
3
|
export declare function normalizeSourceInput(source: SitemapSourceInput): SitemapSourceBase | SitemapSourceResolved;
|
|
4
4
|
export declare function fetchDataSource(input: SitemapSourceBase | SitemapSourceResolved, event?: H3Event): Promise<SitemapSourceResolved>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { defu } from "defu";
|
|
2
|
-
import {
|
|
2
|
+
import { $fetch } from "ofetch";
|
|
3
3
|
import { collectSitemap } from "sitemapd/parse";
|
|
4
4
|
import { parseURL } from "ufo";
|
|
5
|
+
import { getRequestHost } from "#nuxtseo/h3";
|
|
6
|
+
import { fetchWithEvent } from "#nuxtseo/nitro";
|
|
5
7
|
import { logger } from "../../../utils-pure.js";
|
|
6
8
|
const changeFrequencies = /* @__PURE__ */ new Set([
|
|
7
9
|
"always",
|
|
@@ -50,7 +52,7 @@ async function tryFetchWithFallback(url, options, event) {
|
|
|
50
52
|
// Strategy 1: Use globalThis.$fetch (original approach)
|
|
51
53
|
() => globalThis.$fetch(url, options),
|
|
52
54
|
// Strategy 2: If event is available, try using event context even for external URLs
|
|
53
|
-
event ? () => event
|
|
55
|
+
event ? () => fetchWithEvent(event, url, options) : null,
|
|
54
56
|
// Strategy 3: Use native fetch as last resort
|
|
55
57
|
() => $fetch(url, options)
|
|
56
58
|
].filter(Boolean);
|
|
@@ -65,8 +67,7 @@ async function tryFetchWithFallback(url, options, event) {
|
|
|
65
67
|
}
|
|
66
68
|
throw lastError;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
return await fetchContainer.$fetch(url, options);
|
|
70
|
+
return event ? await fetchWithEvent(event, url, options) : await globalThis.$fetch(url, options);
|
|
70
71
|
}
|
|
71
72
|
export async function fetchDataSource(input, event) {
|
|
72
73
|
const context = typeof input.context === "string" ? { name: input.context } : input.context || { name: "fetch" };
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -376,25 +376,25 @@ export interface SitemapDefinition {
|
|
|
376
376
|
*/
|
|
377
377
|
_chunkCount?: number;
|
|
378
378
|
}
|
|
379
|
-
interface NitroBaseHook {
|
|
380
|
-
event:
|
|
379
|
+
interface NitroBaseHook<Event = H3Event> {
|
|
380
|
+
event: Event;
|
|
381
381
|
}
|
|
382
|
-
export interface SitemapIndexRenderCtx extends NitroBaseHook {
|
|
382
|
+
export interface SitemapIndexRenderCtx<Event = H3Event> extends NitroBaseHook<Event> {
|
|
383
383
|
sitemaps: SitemapIndexEntry[];
|
|
384
384
|
}
|
|
385
|
-
export interface SitemapRenderCtx extends NitroBaseHook {
|
|
385
|
+
export interface SitemapRenderCtx<Event = H3Event> extends NitroBaseHook<Event> {
|
|
386
386
|
sitemapName: string;
|
|
387
387
|
urls: ResolvedSitemapUrl[];
|
|
388
388
|
}
|
|
389
|
-
export interface SitemapInputCtx extends NitroBaseHook {
|
|
389
|
+
export interface SitemapInputCtx<Event = H3Event> extends NitroBaseHook<Event> {
|
|
390
390
|
sitemapName: string;
|
|
391
391
|
urls: SitemapUrlInput[];
|
|
392
392
|
}
|
|
393
|
-
export interface SitemapOutputHookCtx extends NitroBaseHook {
|
|
393
|
+
export interface SitemapOutputHookCtx<Event = H3Event> extends NitroBaseHook<Event> {
|
|
394
394
|
sitemapName: string;
|
|
395
395
|
sitemap: string;
|
|
396
396
|
}
|
|
397
|
-
export interface SitemapSourcesHookCtx extends NitroBaseHook {
|
|
397
|
+
export interface SitemapSourcesHookCtx<Event = H3Event> extends NitroBaseHook<Event> {
|
|
398
398
|
sitemapName: string;
|
|
399
399
|
sources: SitemapSourceInput[];
|
|
400
400
|
}
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
import { SitemapUrl } from '../dist/runtime/types.js';
|
|
1
|
+
import { SitemapUrlInput, SitemapUrl } from '../dist/runtime/types.js';
|
|
2
2
|
export * from '../dist/runtime/types.js';
|
|
3
|
+
import { SitemapInput } from 'sitemapd/parse';
|
|
4
|
+
export { CollectSitemapResult, ParseSitemapOptions, SitemapCompleteness, SitemapDocument, SitemapDocumentKind, SitemapExtensions, SitemapFormat, SitemapInput, SitemapIssue, SitemapIssueCode, SitemapParseEvent, SitemapReference, SitemapUrlRecord, collectSitemap, parseSitemap } from 'sitemapd/parse';
|
|
3
5
|
export { SitemapDocumentLoadResult, SitemapDocumentLoader, SitemapLoadFailureCode, SitemapLoadRequest, SitemapLoadSource, SitemapReadOptions, SitemapReadResult, SitemapReader, SitemapReaderOptions, SitemapTargetAuthorization, SitemapTargetAuthorizer, SitemapWalkDocument, SitemapWalkDocumentVisitor, SitemapWalkFailure, SitemapWalkNonRetainedResult, SitemapWalkOptions, SitemapWalkPartialReason, SitemapWalkResult, SitemapWalkRetainedResult, createSitemapReader } from 'sitemapd';
|
|
4
6
|
export { FetchDocumentLoaderOptions, SitemapFetch, createFetchDocumentLoader } from 'sitemapd/fetch';
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
/** @deprecated Use `SitemapIssue` with `parseSitemap` or `collectSitemap`. */
|
|
9
|
+
interface SitemapWarning {
|
|
10
|
+
type: 'validation';
|
|
11
|
+
message: string;
|
|
12
|
+
context?: {
|
|
13
|
+
url?: string;
|
|
14
|
+
field?: string;
|
|
15
|
+
value?: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use the tagged `CollectSitemapResult` returned by `collectSitemap`. */
|
|
19
|
+
interface SitemapParseResult {
|
|
20
|
+
urls: SitemapUrlInput[];
|
|
21
|
+
warnings: SitemapWarning[];
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated Use `SitemapReference`. */
|
|
24
|
+
interface SitemapIndexEntry {
|
|
25
|
+
loc: string;
|
|
26
|
+
lastmod?: string;
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use the tagged `CollectSitemapResult` returned by `collectSitemap`. */
|
|
29
|
+
interface SitemapIndexParseResult {
|
|
30
|
+
entries: SitemapIndexEntry[];
|
|
31
|
+
warnings: SitemapWarning[];
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated Use `SitemapInput`. */
|
|
34
|
+
type SitemapXmlChunk = string | Uint8Array;
|
|
35
|
+
/** @deprecated Use `SitemapInput`. */
|
|
36
|
+
type SitemapXmlInput = SitemapInput;
|
|
37
|
+
/** @deprecated Use `ParseSitemapOptions`. */
|
|
38
|
+
interface SitemapStreamOptions {
|
|
39
|
+
maxEntryBytes?: number;
|
|
40
|
+
maxBufferBytes?: number;
|
|
41
|
+
}
|
|
42
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
43
|
+
type SitemapXmlStreamEvent = {
|
|
44
|
+
_tag: 'url';
|
|
45
|
+
url: SitemapUrlInput;
|
|
46
|
+
} | {
|
|
47
|
+
_tag: 'warning';
|
|
48
|
+
warning: SitemapWarning;
|
|
49
|
+
};
|
|
50
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
51
|
+
type SitemapIndexStreamEvent = {
|
|
52
|
+
_tag: 'sitemap';
|
|
53
|
+
sitemap: SitemapIndexEntry;
|
|
54
|
+
} | {
|
|
55
|
+
_tag: 'warning';
|
|
56
|
+
warning: SitemapWarning;
|
|
57
|
+
};
|
|
58
|
+
/** @deprecated Use `SitemapDocumentKind`. */
|
|
59
|
+
type SitemapKind = 'urlset' | 'index';
|
|
60
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
61
|
+
type SitemapStreamEvent = {
|
|
62
|
+
_tag: 'kind';
|
|
63
|
+
kind: SitemapKind;
|
|
64
|
+
} | SitemapXmlStreamEvent | SitemapIndexStreamEvent;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils`. Canonical
|
|
67
|
+
* streams emit `document`, `url`, `sitemap`, `issue`, and terminal `end`
|
|
68
|
+
* events. URL and sitemap payloads use `entry`.
|
|
69
|
+
*/
|
|
70
|
+
declare function parseSitemapStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapStreamEvent>;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
73
|
+
* events whose document kind is `urlset`.
|
|
74
|
+
*/
|
|
75
|
+
declare function parseSitemapXmlStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapXmlStreamEvent>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
78
|
+
* events whose document kind is `index`.
|
|
79
|
+
*/
|
|
80
|
+
declare function parseSitemapIndexStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapIndexStreamEvent>;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
83
|
+
* its tagged result.
|
|
84
|
+
*/
|
|
85
|
+
declare function parseSitemapXml(xml: string): Promise<SitemapParseResult>;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
88
|
+
* an `index` document result.
|
|
89
|
+
*/
|
|
90
|
+
declare function parseSitemapIndex(xml: string): Promise<SitemapIndexParseResult>;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and inspect
|
|
93
|
+
* the tagged document result.
|
|
94
|
+
*/
|
|
95
|
+
declare function isSitemapIndex(xml: string): boolean;
|
|
6
96
|
|
|
7
97
|
declare function parseHtmlExtractSitemapMeta(html: string, options?: {
|
|
8
98
|
images?: boolean;
|
|
@@ -12,4 +102,5 @@ declare function parseHtmlExtractSitemapMeta(html: string, options?: {
|
|
|
12
102
|
resolveUrl?: (s: string) => string;
|
|
13
103
|
}): Partial<SitemapUrl> | null;
|
|
14
104
|
|
|
15
|
-
export { parseHtmlExtractSitemapMeta };
|
|
105
|
+
export { isSitemapIndex, parseHtmlExtractSitemapMeta, parseSitemapIndex, parseSitemapIndexStream, parseSitemapStream, parseSitemapXml, parseSitemapXmlStream };
|
|
106
|
+
export type { SitemapIndexEntry, SitemapIndexParseResult, SitemapIndexStreamEvent, SitemapKind, SitemapParseResult, SitemapStreamEvent, SitemapStreamOptions, SitemapWarning, SitemapXmlChunk, SitemapXmlInput, SitemapXmlStreamEvent };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,8 +1,98 @@
|
|
|
1
|
-
import { SitemapUrl } from '../dist/runtime/types.js';
|
|
1
|
+
import { SitemapUrlInput, SitemapUrl } from '../dist/runtime/types.js';
|
|
2
2
|
export * from '../dist/runtime/types.js';
|
|
3
|
+
import { SitemapInput } from 'sitemapd/parse';
|
|
4
|
+
export { CollectSitemapResult, ParseSitemapOptions, SitemapCompleteness, SitemapDocument, SitemapDocumentKind, SitemapExtensions, SitemapFormat, SitemapInput, SitemapIssue, SitemapIssueCode, SitemapParseEvent, SitemapReference, SitemapUrlRecord, collectSitemap, parseSitemap } from 'sitemapd/parse';
|
|
3
5
|
export { SitemapDocumentLoadResult, SitemapDocumentLoader, SitemapLoadFailureCode, SitemapLoadRequest, SitemapLoadSource, SitemapReadOptions, SitemapReadResult, SitemapReader, SitemapReaderOptions, SitemapTargetAuthorization, SitemapTargetAuthorizer, SitemapWalkDocument, SitemapWalkDocumentVisitor, SitemapWalkFailure, SitemapWalkNonRetainedResult, SitemapWalkOptions, SitemapWalkPartialReason, SitemapWalkResult, SitemapWalkRetainedResult, createSitemapReader } from 'sitemapd';
|
|
4
6
|
export { FetchDocumentLoaderOptions, SitemapFetch, createFetchDocumentLoader } from 'sitemapd/fetch';
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
/** @deprecated Use `SitemapIssue` with `parseSitemap` or `collectSitemap`. */
|
|
9
|
+
interface SitemapWarning {
|
|
10
|
+
type: 'validation';
|
|
11
|
+
message: string;
|
|
12
|
+
context?: {
|
|
13
|
+
url?: string;
|
|
14
|
+
field?: string;
|
|
15
|
+
value?: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** @deprecated Use the tagged `CollectSitemapResult` returned by `collectSitemap`. */
|
|
19
|
+
interface SitemapParseResult {
|
|
20
|
+
urls: SitemapUrlInput[];
|
|
21
|
+
warnings: SitemapWarning[];
|
|
22
|
+
}
|
|
23
|
+
/** @deprecated Use `SitemapReference`. */
|
|
24
|
+
interface SitemapIndexEntry {
|
|
25
|
+
loc: string;
|
|
26
|
+
lastmod?: string;
|
|
27
|
+
}
|
|
28
|
+
/** @deprecated Use the tagged `CollectSitemapResult` returned by `collectSitemap`. */
|
|
29
|
+
interface SitemapIndexParseResult {
|
|
30
|
+
entries: SitemapIndexEntry[];
|
|
31
|
+
warnings: SitemapWarning[];
|
|
32
|
+
}
|
|
33
|
+
/** @deprecated Use `SitemapInput`. */
|
|
34
|
+
type SitemapXmlChunk = string | Uint8Array;
|
|
35
|
+
/** @deprecated Use `SitemapInput`. */
|
|
36
|
+
type SitemapXmlInput = SitemapInput;
|
|
37
|
+
/** @deprecated Use `ParseSitemapOptions`. */
|
|
38
|
+
interface SitemapStreamOptions {
|
|
39
|
+
maxEntryBytes?: number;
|
|
40
|
+
maxBufferBytes?: number;
|
|
41
|
+
}
|
|
42
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
43
|
+
type SitemapXmlStreamEvent = {
|
|
44
|
+
_tag: 'url';
|
|
45
|
+
url: SitemapUrlInput;
|
|
46
|
+
} | {
|
|
47
|
+
_tag: 'warning';
|
|
48
|
+
warning: SitemapWarning;
|
|
49
|
+
};
|
|
50
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
51
|
+
type SitemapIndexStreamEvent = {
|
|
52
|
+
_tag: 'sitemap';
|
|
53
|
+
sitemap: SitemapIndexEntry;
|
|
54
|
+
} | {
|
|
55
|
+
_tag: 'warning';
|
|
56
|
+
warning: SitemapWarning;
|
|
57
|
+
};
|
|
58
|
+
/** @deprecated Use `SitemapDocumentKind`. */
|
|
59
|
+
type SitemapKind = 'urlset' | 'index';
|
|
60
|
+
/** @deprecated Use `SitemapParseEvent`. */
|
|
61
|
+
type SitemapStreamEvent = {
|
|
62
|
+
_tag: 'kind';
|
|
63
|
+
kind: SitemapKind;
|
|
64
|
+
} | SitemapXmlStreamEvent | SitemapIndexStreamEvent;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils`. Canonical
|
|
67
|
+
* streams emit `document`, `url`, `sitemap`, `issue`, and terminal `end`
|
|
68
|
+
* events. URL and sitemap payloads use `entry`.
|
|
69
|
+
*/
|
|
70
|
+
declare function parseSitemapStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapStreamEvent>;
|
|
71
|
+
/**
|
|
72
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
73
|
+
* events whose document kind is `urlset`.
|
|
74
|
+
*/
|
|
75
|
+
declare function parseSitemapXmlStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapXmlStreamEvent>;
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use `parseSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
78
|
+
* events whose document kind is `index`.
|
|
79
|
+
*/
|
|
80
|
+
declare function parseSitemapIndexStream(input: SitemapXmlInput, options?: SitemapStreamOptions): AsyncGenerator<SitemapIndexStreamEvent>;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
83
|
+
* its tagged result.
|
|
84
|
+
*/
|
|
85
|
+
declare function parseSitemapXml(xml: string): Promise<SitemapParseResult>;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and handle
|
|
88
|
+
* an `index` document result.
|
|
89
|
+
*/
|
|
90
|
+
declare function parseSitemapIndex(xml: string): Promise<SitemapIndexParseResult>;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Use `collectSitemap` from `@nuxtjs/sitemap/utils` and inspect
|
|
93
|
+
* the tagged document result.
|
|
94
|
+
*/
|
|
95
|
+
declare function isSitemapIndex(xml: string): boolean;
|
|
6
96
|
|
|
7
97
|
declare function parseHtmlExtractSitemapMeta(html: string, options?: {
|
|
8
98
|
images?: boolean;
|
|
@@ -12,4 +102,5 @@ declare function parseHtmlExtractSitemapMeta(html: string, options?: {
|
|
|
12
102
|
resolveUrl?: (s: string) => string;
|
|
13
103
|
}): Partial<SitemapUrl> | null;
|
|
14
104
|
|
|
15
|
-
export { parseHtmlExtractSitemapMeta };
|
|
105
|
+
export { isSitemapIndex, parseHtmlExtractSitemapMeta, parseSitemapIndex, parseSitemapIndexStream, parseSitemapStream, parseSitemapXml, parseSitemapXmlStream };
|
|
106
|
+
export type { SitemapIndexEntry, SitemapIndexParseResult, SitemapIndexStreamEvent, SitemapKind, SitemapParseResult, SitemapStreamEvent, SitemapStreamOptions, SitemapWarning, SitemapXmlChunk, SitemapXmlInput, SitemapXmlStreamEvent };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,6 +1,240 @@
|
|
|
1
|
+
import { parseSitemap } from 'sitemapd/parse';
|
|
2
|
+
export { collectSitemap, parseSitemap } from 'sitemapd/parse';
|
|
1
3
|
export { p as parseHtmlExtractSitemapMeta } from './shared/sitemap.BoMnWHOt.mjs';
|
|
2
4
|
export { createSitemapReader } from 'sitemapd';
|
|
3
5
|
export { createFetchDocumentLoader } from 'sitemapd/fetch';
|
|
4
|
-
export { collectSitemap, parseSitemap } from 'sitemapd/parse';
|
|
5
6
|
import 'ufo';
|
|
6
7
|
import 'ultrahtml';
|
|
8
|
+
|
|
9
|
+
const CHANGE_FREQUENCIES = /* @__PURE__ */ new Set([
|
|
10
|
+
"always",
|
|
11
|
+
"hourly",
|
|
12
|
+
"daily",
|
|
13
|
+
"weekly",
|
|
14
|
+
"monthly",
|
|
15
|
+
"yearly",
|
|
16
|
+
"never"
|
|
17
|
+
]);
|
|
18
|
+
function legacyWarning(issue, kind) {
|
|
19
|
+
if (issue.code === "missing_loc") {
|
|
20
|
+
return {
|
|
21
|
+
type: "validation",
|
|
22
|
+
message: kind === "index" ? "Sitemap entry missing required loc element" : "URL entry missing required loc element",
|
|
23
|
+
...kind === "urlset" ? { context: { url: "undefined" } } : {}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (issue.code === "invalid_loc" && kind === "index") {
|
|
27
|
+
const url = String(issue.value);
|
|
28
|
+
if (URL.canParse(url))
|
|
29
|
+
return void 0;
|
|
30
|
+
return {
|
|
31
|
+
type: "validation",
|
|
32
|
+
message: "Sitemap entry has invalid URL",
|
|
33
|
+
context: { url }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (issue.severity !== "warning" || issue.code === "invalid_loc")
|
|
37
|
+
return void 0;
|
|
38
|
+
return {
|
|
39
|
+
type: "validation",
|
|
40
|
+
message: issue.message,
|
|
41
|
+
...issue.field || issue.value !== void 0 ? {
|
|
42
|
+
context: {
|
|
43
|
+
...issue.field ? { field: issue.field } : {},
|
|
44
|
+
...issue.value !== void 0 ? { value: issue.value } : {}
|
|
45
|
+
}
|
|
46
|
+
} : {}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function legacyImages(images) {
|
|
50
|
+
return images?.map((image) => ({
|
|
51
|
+
loc: image.loc,
|
|
52
|
+
...image.caption ? { caption: image.caption } : {},
|
|
53
|
+
...image.geoLocation ? { geo_location: image.geoLocation } : {},
|
|
54
|
+
...image.title ? { title: image.title } : {},
|
|
55
|
+
...image.license ? { license: image.license } : {}
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
function legacyUrl(entry) {
|
|
59
|
+
const warnings = [];
|
|
60
|
+
const url = { loc: entry.loc };
|
|
61
|
+
if (entry.lastmod)
|
|
62
|
+
url.lastmod = entry.lastmod;
|
|
63
|
+
if (entry.changefreq) {
|
|
64
|
+
if (CHANGE_FREQUENCIES.has(entry.changefreq)) {
|
|
65
|
+
url.changefreq = entry.changefreq;
|
|
66
|
+
} else {
|
|
67
|
+
warnings.push({
|
|
68
|
+
type: "validation",
|
|
69
|
+
message: "Invalid changefreq value",
|
|
70
|
+
context: { url: entry.loc, field: "changefreq", value: entry.changefreq }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (entry.priority !== void 0) {
|
|
75
|
+
const priority = Number.parseFloat(entry.priority);
|
|
76
|
+
if (Number.isNaN(priority)) {
|
|
77
|
+
warnings.push({
|
|
78
|
+
type: "validation",
|
|
79
|
+
message: "Invalid priority value",
|
|
80
|
+
context: { url: entry.loc, field: "priority", value: entry.priority }
|
|
81
|
+
});
|
|
82
|
+
} else {
|
|
83
|
+
if (priority < 0 || priority > 1) {
|
|
84
|
+
warnings.push({
|
|
85
|
+
type: "validation",
|
|
86
|
+
message: "Priority value should be between 0.0 and 1.0, clamping to valid range",
|
|
87
|
+
context: { url: entry.loc, field: "priority", value: priority }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
url.priority = Math.max(0, Math.min(1, priority));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const extensions = entry.extensions;
|
|
94
|
+
if (extensions?.alternatives) {
|
|
95
|
+
url.alternatives = extensions.alternatives.flatMap((alternative) => {
|
|
96
|
+
if ((!alternative.rel || alternative.rel === "alternate") && alternative.hreflang)
|
|
97
|
+
return [{ hreflang: alternative.hreflang, href: alternative.href }];
|
|
98
|
+
warnings.push({
|
|
99
|
+
type: "validation",
|
|
100
|
+
message: 'Alternative link missing required rel="alternate", hreflang, or href',
|
|
101
|
+
context: { url: entry.loc, field: "link" }
|
|
102
|
+
});
|
|
103
|
+
return [];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const images = legacyImages(extensions?.images);
|
|
107
|
+
if (images?.length)
|
|
108
|
+
url.images = images;
|
|
109
|
+
if (extensions?.videos?.length)
|
|
110
|
+
url.videos = extensions.videos;
|
|
111
|
+
if (extensions?.news)
|
|
112
|
+
url.news = extensions.news;
|
|
113
|
+
return { url, warnings };
|
|
114
|
+
}
|
|
115
|
+
function positiveOption(value, name) {
|
|
116
|
+
if (value === void 0)
|
|
117
|
+
return void 0;
|
|
118
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
119
|
+
throw new TypeError(`${name} must be a positive safe integer`);
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
function parserFailure(issue, kind, options) {
|
|
123
|
+
if (issue?.code === "empty")
|
|
124
|
+
return new Error("Empty XML input provided");
|
|
125
|
+
if (issue?.code === "decoded_limit" && options.maxBufferBytes)
|
|
126
|
+
return new Error(`Sitemap XML buffer exceeds maxBufferBytes of ${options.maxBufferBytes}`);
|
|
127
|
+
const entryLimit = issue?.message.match(/^Sitemap entry exceeds (\d+) bytes$/);
|
|
128
|
+
if (entryLimit)
|
|
129
|
+
return new Error(`Sitemap entry exceeds maxEntryBytes of ${entryLimit[1]}`);
|
|
130
|
+
if (issue?.code === "unsupported" || issue?.code === "html") {
|
|
131
|
+
return new Error(
|
|
132
|
+
kind === "index" ? "XML does not contain a valid sitemapindex element" : kind === "urlset" ? "XML does not contain a valid urlset element" : "XML does not contain a valid sitemap element"
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
return new Error(`Failed to parse XML: ${issue?.message || "Malformed sitemap"}`);
|
|
136
|
+
}
|
|
137
|
+
async function* parseSitemapStreamInternal(input, options = {}, expectedKind) {
|
|
138
|
+
const maxEntryBytes = positiveOption(options.maxEntryBytes, "maxEntryBytes");
|
|
139
|
+
const maxBufferBytes = positiveOption(options.maxBufferBytes, "maxBufferBytes");
|
|
140
|
+
let kind;
|
|
141
|
+
let lastIssue;
|
|
142
|
+
let invalidUrlEntries = 0;
|
|
143
|
+
let validUrls = 0;
|
|
144
|
+
for await (const event of parseSitemap(input, {
|
|
145
|
+
...maxEntryBytes ? { maxEntryBytes } : {},
|
|
146
|
+
...maxBufferBytes ? { maxDecodedBytes: maxBufferBytes } : {}
|
|
147
|
+
})) {
|
|
148
|
+
if (event._tag === "document") {
|
|
149
|
+
if (event.format !== "xml") {
|
|
150
|
+
throw new Error(
|
|
151
|
+
expectedKind === "index" ? "XML does not contain a valid sitemapindex element" : expectedKind === "urlset" ? "XML does not contain a valid urlset element" : "XML does not contain a valid sitemap element"
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
kind = event.kind;
|
|
155
|
+
yield { _tag: "kind", kind };
|
|
156
|
+
} else if (event._tag === "issue") {
|
|
157
|
+
lastIssue = event.issue;
|
|
158
|
+
if (!kind)
|
|
159
|
+
continue;
|
|
160
|
+
if (event.issue.code === "missing_loc" && kind === "urlset")
|
|
161
|
+
invalidUrlEntries++;
|
|
162
|
+
const warning = legacyWarning(event.issue, kind);
|
|
163
|
+
if (warning)
|
|
164
|
+
yield { _tag: "warning", warning };
|
|
165
|
+
} else if (event._tag === "url") {
|
|
166
|
+
validUrls++;
|
|
167
|
+
const mapped = legacyUrl(event.entry);
|
|
168
|
+
for (const warning of mapped.warnings)
|
|
169
|
+
yield { _tag: "warning", warning };
|
|
170
|
+
yield { _tag: "url", url: mapped.url };
|
|
171
|
+
} else if (event._tag === "sitemap") {
|
|
172
|
+
if (!URL.canParse(event.entry.loc))
|
|
173
|
+
continue;
|
|
174
|
+
yield { _tag: "sitemap", sitemap: event.entry };
|
|
175
|
+
} else if (event.completeness._tag !== "complete") {
|
|
176
|
+
throw parserFailure(lastIssue, kind || expectedKind, options);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (kind === "urlset" && invalidUrlEntries > 0 && validUrls === 0) {
|
|
180
|
+
yield {
|
|
181
|
+
_tag: "warning",
|
|
182
|
+
warning: {
|
|
183
|
+
type: "validation",
|
|
184
|
+
message: "No valid URLs found in sitemap after validation"
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async function* parseSitemapStream(input, options = {}) {
|
|
190
|
+
yield* parseSitemapStreamInternal(input, options);
|
|
191
|
+
}
|
|
192
|
+
async function* parseSitemapXmlStream(input, options = {}) {
|
|
193
|
+
for await (const event of parseSitemapStreamInternal(input, options, "urlset")) {
|
|
194
|
+
if (event._tag === "kind") {
|
|
195
|
+
if (event.kind !== "urlset")
|
|
196
|
+
throw new Error("XML does not contain a valid urlset element");
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (event._tag !== "sitemap")
|
|
200
|
+
yield event;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async function* parseSitemapIndexStream(input, options = {}) {
|
|
204
|
+
for await (const event of parseSitemapStreamInternal(input, options, "index")) {
|
|
205
|
+
if (event._tag === "kind") {
|
|
206
|
+
if (event.kind !== "index")
|
|
207
|
+
throw new Error("XML does not contain a valid sitemapindex element");
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (event._tag !== "url")
|
|
211
|
+
yield event;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async function parseSitemapXml(xml) {
|
|
215
|
+
const urls = [];
|
|
216
|
+
const warnings = [];
|
|
217
|
+
for await (const event of parseSitemapXmlStream(xml)) {
|
|
218
|
+
if (event._tag === "url")
|
|
219
|
+
urls.push(event.url);
|
|
220
|
+
else
|
|
221
|
+
warnings.push(event.warning);
|
|
222
|
+
}
|
|
223
|
+
return { urls, warnings };
|
|
224
|
+
}
|
|
225
|
+
async function parseSitemapIndex(xml) {
|
|
226
|
+
const entries = [];
|
|
227
|
+
const warnings = [];
|
|
228
|
+
for await (const event of parseSitemapIndexStream(xml)) {
|
|
229
|
+
if (event._tag === "sitemap")
|
|
230
|
+
entries.push(event.sitemap);
|
|
231
|
+
else
|
|
232
|
+
warnings.push(event.warning);
|
|
233
|
+
}
|
|
234
|
+
return { entries, warnings };
|
|
235
|
+
}
|
|
236
|
+
function isSitemapIndex(xml) {
|
|
237
|
+
return xml.includes("<sitemapindex") || xml.includes("sitemapindex>");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export { isSitemapIndex, parseSitemapIndex, parseSitemapIndexStream, parseSitemapStream, parseSitemapXml, parseSitemapXmlStream };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuxtjs/sitemap",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.3.
|
|
4
|
+
"version": "8.3.3",
|
|
5
5
|
"description": "Powerfully flexible XML Sitemaps that integrate seamlessly, for Nuxt.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
"@nuxt/kit": "^4.5.1",
|
|
59
59
|
"consola": "^3.4.2",
|
|
60
60
|
"defu": "^6.1.7",
|
|
61
|
-
"nuxt-site-config": "^4.1.
|
|
62
|
-
"nuxtseo-shared": "^5.3.
|
|
61
|
+
"nuxt-site-config": "^4.1.5",
|
|
62
|
+
"nuxtseo-shared": "^5.3.10",
|
|
63
63
|
"ofetch": "^1.5.1",
|
|
64
64
|
"pathe": "^2.0.3",
|
|
65
65
|
"pkg-types": "^2.3.1",
|
|
66
66
|
"radix3": "^1.1.2",
|
|
67
67
|
"ufo": "^1.6.4",
|
|
68
68
|
"ultrahtml": "^1.7.0",
|
|
69
|
-
"sitemapd": "^0.2.
|
|
69
|
+
"sitemapd": "^0.2.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@antfu/eslint-config": "^9.2.0",
|
|
@@ -76,24 +76,24 @@
|
|
|
76
76
|
"@nuxt/module-builder": "^1.0.3",
|
|
77
77
|
"@nuxt/test-utils": "^4.1.0",
|
|
78
78
|
"@nuxt/ui": "^4.10.0",
|
|
79
|
-
"@nuxtjs/i18n": "^10.
|
|
79
|
+
"@nuxtjs/i18n": "^10.6.0",
|
|
80
80
|
"@nuxtjs/robots": "^6.1.3",
|
|
81
81
|
"@vue/test-utils": "^2.4.11",
|
|
82
|
-
"better-sqlite3": "^13.0.
|
|
83
|
-
"bumpp": "^12.1.
|
|
82
|
+
"better-sqlite3": "^13.0.2",
|
|
83
|
+
"bumpp": "^12.1.1",
|
|
84
84
|
"eslint": "^10.8.0",
|
|
85
85
|
"eslint-plugin-harlanzw": "^0.17.1",
|
|
86
86
|
"happy-dom": "^20.11.1",
|
|
87
87
|
"nuxt": "^4.5.1",
|
|
88
|
-
"nuxt-i18n-micro": "^3.
|
|
89
|
-
"nuxtseo-layer-devtools": "^5.3.
|
|
88
|
+
"nuxt-i18n-micro": "^3.26.0",
|
|
89
|
+
"nuxtseo-layer-devtools": "^5.3.10",
|
|
90
90
|
"std-env": "^4.2.0",
|
|
91
91
|
"typescript": "6.0.3",
|
|
92
92
|
"unbuild": "^3.6.1",
|
|
93
93
|
"vitest": "^4.1.10",
|
|
94
|
-
"vue-tsc": "^3.3.
|
|
94
|
+
"vue-tsc": "^3.3.9",
|
|
95
95
|
"zod": "^4.4.3",
|
|
96
|
-
"@nuxtjs/sitemap": "8.3.
|
|
96
|
+
"@nuxtjs/sitemap": "8.3.3"
|
|
97
97
|
},
|
|
98
98
|
"scripts": {
|
|
99
99
|
"lint": "eslint .",
|
|
@@ -106,8 +106,9 @@
|
|
|
106
106
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground && pnpm run client:build",
|
|
107
107
|
"release": "pnpm build && bumpp -x \"npx changelogen --output=CHANGELOG.md\"",
|
|
108
108
|
"release:sitemapd": "pnpm --filter sitemapd release",
|
|
109
|
-
"test": "pnpm --filter sitemapd test && vitest run && pnpm run test:attw",
|
|
109
|
+
"test": "pnpm --filter sitemapd test && vitest run && pnpm run test:attw && pnpm run test:nuxt5",
|
|
110
110
|
"test:unit": "vitest --project=unit",
|
|
111
|
+
"test:nuxt5": "pnpm pack --out test/fixtures/nuxt5/module.tgz && pnpm install --dir test/fixtures/nuxt5 --no-frozen-lockfile --update-checksums && pnpm --dir test/fixtures/nuxt5 test",
|
|
111
112
|
"test:attw": "attw --pack && pnpm --filter sitemapd test:attw",
|
|
112
113
|
"typecheck": "pnpm --filter sitemapd typecheck && nuxt typecheck"
|
|
113
114
|
}
|