sveltekit-sitemap
Advanced tools
Comparing version 1.0.20 to 1.0.21
import * as type_fest_source_readonly_deep from 'type-fest/source/readonly-deep'; | ||
import { S as Sitemap, a as SitemapParams, R as RouteDefinitions, U as UserAgentDirective } from './types-316b26a7.js'; | ||
export { D as DynamicRoutes, E as Event, F as Folders, P as PathDirectives, b as RO_Sitemap, i as ReplaceParams, f as RouteDefinition, g as RouteDefinitionImage, d as Routes, h as SitemapPluginParams, e as StaticRoutes, c as Str } from './types-316b26a7.js'; | ||
import { S as Sitemap, a as SitemapParams, R as RouteDefinitions, U as UserAgentDirective } from './types-c3565dac.js'; | ||
export { D as DynamicRoutes, E as Event, F as Folders, P as PathDirectives, b as RO_Sitemap, i as ReplaceParams, f as RouteDefinition, g as RouteDefinitionImage, d as Routes, h as SitemapPluginParams, e as StaticRoutes, c as Str } from './types-c3565dac.js'; | ||
import { Handle } from '@sveltejs/kit'; | ||
@@ -5,0 +5,0 @@ import 'type-fest'; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4DJVROEEjs = require('./chunk-4DJVROEE.js');function x(r,n){let t=new Headers(n==null?void 0:n.headers);return t.has("content-type")||t.set("content-type","application/json"),new Response(JSON.stringify(r),_chunk4DJVROEEjs.b.call(void 0, _chunk4DJVROEEjs.a.call(void 0, {},n),{headers:t}))}var c=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),d= exports.generateSitemap =(r,n,t,l)=>{let i=Object.keys(t).reduce((s,e)=>(e.includes("[")||Object.assign(s,{[e]:{path:e,priority:e==="/"?"1.0":"0.7"}}),s),{});return Object.entries(t).forEach(([s])=>{let e=r[s];e&&(Array.isArray(e)?e.forEach(o=>{Object.assign(i,{[o.path]:o})}):Object.assign(i,{[(e==null?void 0:e.path)||s]:e}))}),l===!0?Object.entries(i):`<?xml version="1.0" encoding="UTF-8"?> | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4DJVROEEjs = require('./chunk-4DJVROEE.js');function d(r,i){let t=new Headers(i==null?void 0:i.headers);return t.has("content-type")||t.set("content-type","application/json"),new Response(JSON.stringify(r),_chunk4DJVROEEjs.b.call(void 0, _chunk4DJVROEEjs.a.call(void 0, {},i),{headers:t}))}var c=r=>r.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),y= exports.generateSitemap =(r,i,t,l)=>{let a=Object.keys(t).reduce((s,e)=>(!e.includes("[")&&r[e]!==!1&&Object.assign(s,{[e]:{path:e,priority:e==="/"?"1.0":"0.7"}}),s),{});return Object.entries(t).forEach(([s])=>{let e=r[s];e&&(Array.isArray(e)?e.forEach(o=>{o&&Object.assign(a,{[o.path]:o})}):Object.assign(a,{[(e==null?void 0:e.path)||s]:e}))}),l===!0?Object.entries(a):`<?xml version="1.0" encoding="UTF-8"?> | ||
<urlset | ||
@@ -12,21 +12,21 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:xhtml="http://www.w3.org/1999/xhtml"> | ||
${Object.entries(i).map(([s,{path:e,priority:o,changeFreq:a,image:m,lastMod:g}])=>{var w,h;return` <url> | ||
<loc>${n}${e||s}</loc> | ||
${Object.entries(a).map(([s,e])=>{var h,f;if(!e)return"";let{path:o,priority:n,changeFreq:g,image:m,lastMod:w}=e;return` <url> | ||
<loc>${i}${o||s}</loc> | ||
</url> | ||
${g?`<lastmod>${g}</lastmod>`:""} | ||
${o?`<priority>${o}</priority>`:""} | ||
${a?`<changefreq>${a}</changefreq>`:""} | ||
${w?`<lastmod>${w}</lastmod>`:""} | ||
${n?`<priority>${n}</priority>`:""} | ||
${g?`<changefreq>${g}</changefreq>`:""} | ||
${m?` | ||
<image:image> | ||
<image:loc>${c(m.url)}</image:loc> | ||
<image:title>${c((w=m.title)!=null?w:" ")}</image:title> | ||
<image:caption>${c((h=m.altText)!=null?h:" ")}</image:caption> | ||
<image:title>${c((h=m.title)!=null?h:" ")}</image:title> | ||
<image:caption>${c((f=m.altText)!=null?f:" ")}</image:caption> | ||
</image:image>`:""}`}).join(` | ||
`)} | ||
</urlset>`},y= exports.generateRobots =(r,n)=>{let t=[],l=i=>{let s=Object.entries(i.paths).reduce((e,[o,a])=>(a?e.allow.push(o):e.disallow.push(o),e),{allow:[],disallow:[]});Array.isArray(i.userAgent)?i.userAgent.forEach(e=>{t.push(_chunk4DJVROEEjs.a.call(void 0, {agent:e,crawlDelay:i.crawlDelay},s))}):t.push(_chunk4DJVROEEjs.a.call(void 0, {agent:i.userAgent||"*",crawlDelay:i.crawlDelay},s))};return typeof r=="boolean"?t.push({agent:"*",allow:r===!0?["/"]:[],disallow:r===!1?["/"]:[]}):Array.isArray(r)?r.forEach(l):l(r),`${t.map(({agent:i,crawlDelay:s,allow:e,disallow:o})=>`User-agent: ${i} | ||
Sitemap: ${n}/sitemap.xml | ||
</urlset>`},S= exports.generateRobots =(r,i)=>{let t=[],l=a=>{let s=Object.entries(a.paths).reduce((e,[o,n])=>(n?e.allow.push(o):e.disallow.push(o),e),{allow:[],disallow:[]});Array.isArray(a.userAgent)?a.userAgent.forEach(e=>{t.push(_chunk4DJVROEEjs.a.call(void 0, {agent:e,crawlDelay:a.crawlDelay},s))}):t.push(_chunk4DJVROEEjs.a.call(void 0, {agent:a.userAgent||"*",crawlDelay:a.crawlDelay},s))};return typeof r=="boolean"?t.push({agent:"*",allow:r===!0?["/"]:[],disallow:r===!1?["/"]:[]}):Array.isArray(r)?r.forEach(l):l(r),`${t.map(({agent:a,crawlDelay:s,allow:e,disallow:o})=>`User-agent: ${a} | ||
Sitemap: ${i}/sitemap.xml | ||
${s?`Crawl-delay: ${s}`:""} | ||
${e.map(a=>`Allow: ${a}`).join(` | ||
${e.map(n=>`Allow: ${n}`).join(` | ||
`)} | ||
${o.map(a=>`Disallow: ${a}`).join(` | ||
${o.map(n=>`Disallow: ${n}`).join(` | ||
`)} | ||
@@ -37,3 +37,3 @@ `.replace(/\n\n/g,` | ||
`)} | ||
`.trim()};var P=(r,n={})=>i=>_chunk4DJVROEEjs.c.call(void 0, void 0,[i],function*({event:t,resolve:l}){if(t.url.pathname==="/sitemap.xml"){let s=n.getRoutes?yield n.getRoutes(t):{},e=t.url.searchParams.get("format")==="json",o=d(s,t.url.origin,r,e);return e?x(o):new Response(o,{status:200,headers:{"Content-Type":"application/xml"}})}if(t.url.pathname==="/robots.txt"){let s=n.getRobots?yield n.getRobots(t):!0;return new Response(y(s,t.url.origin),{headers:{"content-type":"text/plain","cache-control":`max-age=${60*60*24}`}})}return l(t)});exports.encodeXML = c; exports.generateRobots = y; exports.generateSitemap = d; exports.sitemapHook = P; | ||
`.trim()};var v=(r,i={})=>a=>_chunk4DJVROEEjs.c.call(void 0, void 0,[a],function*({event:t,resolve:l}){if(t.url.pathname==="/sitemap.xml"){let s=i.getRoutes?yield i.getRoutes(t):{},e=t.url.searchParams.get("format")==="json",o=y(s,t.url.origin,r,e);return e?d(o):new Response(o,{status:200,headers:{"Content-Type":"application/xml"}})}if(t.url.pathname==="/robots.txt"){let s=i.getRobots?yield i.getRobots(t):!0;return new Response(S(s,t.url.origin),{headers:{"content-type":"text/plain","cache-control":`max-age=${60*60*24}`}})}return l(t)});exports.encodeXML = c; exports.generateRobots = S; exports.generateSitemap = y; exports.sitemapHook = v; | ||
//# sourceMappingURL=index.js.map |
import { ViteDevServer } from 'vite'; | ||
import { h as SitemapPluginParams } from './types-316b26a7.js'; | ||
import { h as SitemapPluginParams } from './types-c3565dac.js'; | ||
import '@sveltejs/kit'; | ||
@@ -4,0 +4,0 @@ import 'type-fest'; |
{ | ||
"name": "sveltekit-sitemap", | ||
"version": "1.0.20", | ||
"version": "1.0.21", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -23,36 +23,38 @@ import { RequestEvent } from "@sveltejs/kit"; | ||
type Frequency = "Always" | "Hourly" | "Weekly" | "Monthly" | "Yearly" | "Never"; | ||
export type RouteDefinition<S extends boolean> = SetOptional< | ||
{ | ||
path: string; | ||
lastMod?: string; | ||
/** | ||
* 1. Always | ||
* These page types are constantly changing and will include index pages on major news publications, Google News, stock market data, and social bookmarking categories. | ||
* 2. Hourly | ||
* These pages update every hour and will also include major news publications as well as weather services and forums. | ||
* 3. Daily | ||
* Pages updated on average once per day and include things like blog posts, smaller web forum pages, message boards, and classified ads. | ||
* 4. Weekly | ||
* Updates typically occur once per week, these pages will include website directories, product pricing pages, and smaller blogs. | ||
* 5. Monthly | ||
* These are updated once per month, give or take, and include category pages, FAQs, and sometimes Help Desk articles that change slightly. Refer to the section above for guidelines on what is considered to be a change frequency trigger. | ||
* 6. Yearly | ||
* Updates on these pages happen on an annual basis and are typically your contact page, “About” page, login pages, and registration pages. | ||
* 7. Never | ||
* As the name suggests, these pages never ever get updates. These are really old blog posts, press releases, notifications about updates that never need updating, and completely static pages. | ||
*/ | ||
changeFreq?: Frequency; | ||
/** | ||
* 1.0-0.8 | ||
* Homepage, product information, landing pages. | ||
* 0.7-0.4 | ||
* News articles, some weather services, blog posts, pages that no site would be complete without. | ||
* 0.3-0.0 | ||
* FAQs, outdated info, old press releases, completely static pages that are still relevant enough to keep from deleting entirely. | ||
*/ | ||
priority?: Priority; | ||
image?: RouteDefinitionImage; | ||
}, | ||
S extends true ? "path" : never | ||
>; | ||
export type RouteDefinition<S extends boolean> = | ||
| false | ||
| SetOptional< | ||
{ | ||
path: string; | ||
lastMod?: string; | ||
/** | ||
* 1. Always | ||
* These page types are constantly changing and will include index pages on major news publications, Google News, stock market data, and social bookmarking categories. | ||
* 2. Hourly | ||
* These pages update every hour and will also include major news publications as well as weather services and forums. | ||
* 3. Daily | ||
* Pages updated on average once per day and include things like blog posts, smaller web forum pages, message boards, and classified ads. | ||
* 4. Weekly | ||
* Updates typically occur once per week, these pages will include website directories, product pricing pages, and smaller blogs. | ||
* 5. Monthly | ||
* These are updated once per month, give or take, and include category pages, FAQs, and sometimes Help Desk articles that change slightly. Refer to the section above for guidelines on what is considered to be a change frequency trigger. | ||
* 6. Yearly | ||
* Updates on these pages happen on an annual basis and are typically your contact page, “About” page, login pages, and registration pages. | ||
* 7. Never | ||
* As the name suggests, these pages never ever get updates. These are really old blog posts, press releases, notifications about updates that never need updating, and completely static pages. | ||
*/ | ||
changeFreq?: Frequency; | ||
/** | ||
* 1.0-0.8 | ||
* Homepage, product information, landing pages. | ||
* 0.7-0.4 | ||
* News articles, some weather services, blog posts, pages that no site would be complete without. | ||
* 0.3-0.0 | ||
* FAQs, outdated info, old press releases, completely static pages that are still relevant enough to keep from deleting entirely. | ||
*/ | ||
priority?: Priority; | ||
image?: RouteDefinitionImage; | ||
}, | ||
S extends true ? "path" : never | ||
>; | ||
export type RouteDefinitionImage = { | ||
@@ -59,0 +61,0 @@ url: string; |
@@ -22,3 +22,3 @@ import { RO_Sitemap, RouteDefinitions, RouteDefinition, Sitemap, UserAgentDirective } from "./types"; | ||
const isDynamic = route.includes("["); | ||
if (!isDynamic) { | ||
if (!isDynamic && definitions[route as keyof typeof definitions] !== false) { | ||
Object.assign(acc, { | ||
@@ -37,3 +37,5 @@ [route]: { path: route, priority: route === "/" ? "1.0" : "0.7" } as RouteDefinition<boolean> | ||
RouteDefinition.forEach((definition) => { | ||
Object.assign(routes, { [definition.path]: definition }); | ||
if (definition) { | ||
Object.assign(routes, { [definition.path]: definition }); | ||
} | ||
}); | ||
@@ -63,3 +65,6 @@ } else { | ||
${Object.entries(routes) | ||
.map(([r, { path, priority, changeFreq, image, lastMod }]) => { | ||
.map(([r, d]) => { | ||
if (!d) return ""; | ||
const { path, priority, changeFreq, image, lastMod } = d; | ||
return ` <url> | ||
@@ -66,0 +71,0 @@ <loc>${baseUrl}${path || r}</loc> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79658
45
744