Fix
This commit is contained in:
Vendored
+1
-1
@@ -56,4 +56,4 @@ export type SitemapRouteOptions = {
|
||||
* `GET /sitemap.xml` → XML (crawlers), `GET /sitemap.xml?style` → its CSS.
|
||||
* Don't keep app/sitemap.ts next to it — two sitemaps confuse crawlers.
|
||||
*/
|
||||
export declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: SitemapRouteOptions): (req: Request) => Promise<Response>;
|
||||
export declare function createSitemapRouteHandler(sitemap: () => Promise<SitemapEntry[]>, opts?: SitemapRouteOptions): (req?: Request) => Promise<Response>;
|
||||
|
||||
Vendored
+3
-3
@@ -62,8 +62,8 @@ import { buildSitemapCss, SITEMAP_STYLE_PARAM } from './sitemapStyle.js';
|
||||
*/ export function createSitemapRouteHandler(sitemap, opts = {}) {
|
||||
const style = opts.cssUrl ? false : opts.style === false ? false : opts.style ?? {};
|
||||
return async (req)=>{
|
||||
const url = new URL(req.url);
|
||||
if (style && url.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||
const url = req ? new URL(req.url) : null;
|
||||
if (style && url?.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||
let title;
|
||||
try {
|
||||
title = typeof style.title === 'function' ? await style.title() : style.title;
|
||||
@@ -81,7 +81,7 @@ import { buildSitemapCss, SITEMAP_STYLE_PARAM } from './sitemapStyle.js';
|
||||
}
|
||||
});
|
||||
}
|
||||
const cssUrl = opts.cssUrl ?? (style ? `${url.pathname}?${SITEMAP_STYLE_PARAM}` : undefined);
|
||||
const cssUrl = opts.cssUrl ?? (style ? `${url?.pathname ?? '/sitemap.xml'}?${SITEMAP_STYLE_PARAM}` : undefined);
|
||||
try {
|
||||
const entries = await sitemap();
|
||||
const xml = buildSitemapXml(entries, {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user