svelte-sitemap 4.0.2 → 4.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dto/global.interface.d.ts +14 -2
- package/helpers/config.js +2 -1
- package/helpers/config.js.map +1 -1
- package/helpers/file.js +1 -1
- package/helpers/global.helper.js +62 -16
- package/helpers/global.helper.js.map +1 -1
- package/index.d.ts +2 -2
- package/package.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -188,6 +188,89 @@ Migrating from the CLI or config file to the Vite plugin is quick and straightfo
|
|
|
188
188
|
|
|
189
189
|
---
|
|
190
190
|
|
|
191
|
+
## 🔄 Transform
|
|
192
|
+
|
|
193
|
+
The `transform` option gives you full control over each sitemap entry. It receives the config and the page path, and returns a `SitemapField` object (or `null` to skip the page).
|
|
194
|
+
|
|
195
|
+
This is useful for setting per-page `priority`, `changefreq`, or adding `alternateRefs` for multilingual sites.
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
// svelte-sitemap.config.ts
|
|
199
|
+
import type { OptionsSvelteSitemap } from 'svelte-sitemap';
|
|
200
|
+
|
|
201
|
+
const config: OptionsSvelteSitemap = {
|
|
202
|
+
domain: 'https://example.com',
|
|
203
|
+
transform: async (config, path) => {
|
|
204
|
+
return {
|
|
205
|
+
loc: path,
|
|
206
|
+
changefreq: 'weekly',
|
|
207
|
+
priority: path === '/' ? 1.0 : 0.7,
|
|
208
|
+
lastmod: new Date().toISOString().split('T')[0]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default config;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Excluding pages via transform
|
|
217
|
+
|
|
218
|
+
Return `null` to exclude a page from the sitemap:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
transform: async (config, path) => {
|
|
222
|
+
if (path.startsWith('/admin')) {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
return { loc: path };
|
|
226
|
+
};
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Alternate refs (hreflang) for multilingual sites
|
|
230
|
+
|
|
231
|
+
Use `alternateRefs` inside `transform` to add `<xhtml:link rel="alternate" />` entries for each language version of a page. The `xmlns:xhtml` namespace is automatically added to the sitemap only when alternateRefs are present.
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// svelte-sitemap.config.ts
|
|
235
|
+
import type { OptionsSvelteSitemap } from 'svelte-sitemap';
|
|
236
|
+
|
|
237
|
+
const config: OptionsSvelteSitemap = {
|
|
238
|
+
domain: 'https://example.com',
|
|
239
|
+
transform: async (config, path) => {
|
|
240
|
+
return {
|
|
241
|
+
loc: path,
|
|
242
|
+
changefreq: 'daily',
|
|
243
|
+
priority: 0.7,
|
|
244
|
+
alternateRefs: [
|
|
245
|
+
{ href: `https://example.com${path}`, hreflang: 'en' },
|
|
246
|
+
{ href: `https://es.example.com${path}`, hreflang: 'es' },
|
|
247
|
+
{ href: `https://fr.example.com${path}`, hreflang: 'fr' }
|
|
248
|
+
]
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export default config;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
This produces:
|
|
257
|
+
|
|
258
|
+
```xml
|
|
259
|
+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
|
|
260
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
261
|
+
<url>
|
|
262
|
+
<loc>https://example.com/</loc>
|
|
263
|
+
<changefreq>daily</changefreq>
|
|
264
|
+
<priority>0.7</priority>
|
|
265
|
+
<xhtml:link rel="alternate" hreflang="en" href="https://example.com/" />
|
|
266
|
+
<xhtml:link rel="alternate" hreflang="es" href="https://es.example.com/" />
|
|
267
|
+
<xhtml:link rel="alternate" hreflang="fr" href="https://fr.example.com/" />
|
|
268
|
+
</url>
|
|
269
|
+
</urlset>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
> **Tip:** Following Google's guidelines, each URL should include an alternate link pointing to itself as well.
|
|
273
|
+
|
|
191
274
|
## 🙋 FAQ
|
|
192
275
|
|
|
193
276
|
### 🙈 How to exclude a directory?
|
|
@@ -54,6 +54,7 @@ interface Options {
|
|
|
54
54
|
* @example `additional: ['my-page', 'my-second-page']`
|
|
55
55
|
*/
|
|
56
56
|
additional?: string[];
|
|
57
|
+
transform?: (config: OptionsSvelteSitemap, path: string) => Promise<SitemapField | null | undefined> | SitemapField | null | undefined;
|
|
57
58
|
}
|
|
58
59
|
interface OptionsSvelteSitemap extends Options {
|
|
59
60
|
/**
|
|
@@ -61,11 +62,22 @@ interface OptionsSvelteSitemap extends Options {
|
|
|
61
62
|
*/
|
|
62
63
|
domain: string;
|
|
63
64
|
}
|
|
65
|
+
interface SitemapFieldAlternateRef {
|
|
66
|
+
href: string;
|
|
67
|
+
hreflang: string;
|
|
68
|
+
}
|
|
69
|
+
interface SitemapField {
|
|
70
|
+
loc: string;
|
|
71
|
+
lastmod?: string;
|
|
72
|
+
changefreq?: ChangeFreq;
|
|
73
|
+
priority?: number | string;
|
|
74
|
+
alternateRefs?: Array<SitemapFieldAlternateRef>;
|
|
75
|
+
}
|
|
64
76
|
interface PagesJson {
|
|
65
77
|
/**
|
|
66
78
|
* The path or URL of the page.
|
|
67
79
|
*/
|
|
68
|
-
page
|
|
80
|
+
page?: string;
|
|
69
81
|
/**
|
|
70
82
|
* How frequently the page content is likely to change.
|
|
71
83
|
*/
|
|
@@ -80,5 +92,5 @@ interface PagesJson {
|
|
|
80
92
|
*/
|
|
81
93
|
type ChangeFreq = (typeof CHANGE_FREQ)[number];
|
|
82
94
|
//#endregion
|
|
83
|
-
export { Arguments, ChangeFreq, Options, OptionsSvelteSitemap, PagesJson };
|
|
95
|
+
export { Arguments, ChangeFreq, Options, OptionsSvelteSitemap, PagesJson, SitemapField, SitemapFieldAlternateRef };
|
|
84
96
|
//# sourceMappingURL=global.interface.d.ts.map
|
package/helpers/config.js
CHANGED
package/helpers/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["import { OUT_DIR } from '../const.js';\nimport type { OptionsSvelteSitemap } from '../dto/index.js';\nimport { loadFile } from './file.js';\n\nexport const loadConfig = async (paths: string[]): Promise<OptionsSvelteSitemap | undefined> => {\n for (const path of paths) {\n const config = await loadFile<OptionsSvelteSitemap>(path, false);\n if (config) {\n return config;\n }\n }\n return undefined;\n};\n\nexport const defaultConfig: OptionsSvelteSitemap = {\n debug: false,\n changeFreq: null,\n resetTime: false,\n outDir: OUT_DIR,\n attribution: true,\n ignore: null,\n trailingSlashes: false,\n domain: null\n};\n\nexport const updateConfig = (\n currConfig: OptionsSvelteSitemap,\n newConfig: OptionsSvelteSitemap\n): OptionsSvelteSitemap => {\n return { ...currConfig, ...newConfig };\n};\n\nexport const withDefaultConfig = (config: OptionsSvelteSitemap): OptionsSvelteSitemap => {\n return updateConfig(defaultConfig, config);\n};\n"],"mappings":";;;AAIA,MAAa,aAAa,OAAO,UAA+D;CAC9F,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,MAAM,SAA+B,MAAM,KAAK;EAC/D,IAAI,QACF,OAAO;CAEX;AAEF;AAEA,MAAa,gBAAsC;CACjD,OAAO;CACP,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,iBAAiB;CACjB,QAAQ;
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["import { OUT_DIR } from '../const.js';\nimport type { OptionsSvelteSitemap } from '../dto/index.js';\nimport { loadFile } from './file.js';\n\nexport const loadConfig = async (paths: string[]): Promise<OptionsSvelteSitemap | undefined> => {\n for (const path of paths) {\n const config = await loadFile<OptionsSvelteSitemap>(path, false);\n if (config) {\n return config;\n }\n }\n return undefined;\n};\n\nexport const defaultConfig: OptionsSvelteSitemap = {\n debug: false,\n changeFreq: null,\n resetTime: false,\n outDir: OUT_DIR,\n attribution: true,\n ignore: null,\n trailingSlashes: false,\n domain: null,\n transform: null\n};\n\nexport const updateConfig = (\n currConfig: OptionsSvelteSitemap,\n newConfig: OptionsSvelteSitemap\n): OptionsSvelteSitemap => {\n return { ...currConfig, ...newConfig };\n};\n\nexport const withDefaultConfig = (config: OptionsSvelteSitemap): OptionsSvelteSitemap => {\n return updateConfig(defaultConfig, config);\n};\n"],"mappings":";;;AAIA,MAAa,aAAa,OAAO,UAA+D;CAC9F,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,MAAM,SAA+B,MAAM,KAAK;EAC/D,IAAI,QACF,OAAO;CAEX;AAEF;AAEA,MAAa,gBAAsC;CACjD,OAAO;CACP,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,iBAAiB;CACjB,QAAQ;CACR,WAAW;AACb;AAEA,MAAa,gBACX,YACA,cACyB;CACzB,OAAO;EAAE,GAAG;EAAY,GAAG;CAAU;AACvC;AAEA,MAAa,qBAAqB,WAAuD;CACvF,OAAO,aAAa,eAAe,MAAM;AAC3C"}
|
package/helpers/file.js
CHANGED
package/helpers/global.helper.js
CHANGED
|
@@ -3,7 +3,6 @@ import { version as version$1 } from "../package.js";
|
|
|
3
3
|
import { cliColors, errorMsgFolder, errorMsgHtmlFiles, errorMsgWrite, successMsg } from "./vars.helper.js";
|
|
4
4
|
import fg from "fast-glob";
|
|
5
5
|
import fs from "fs";
|
|
6
|
-
import path from "path";
|
|
7
6
|
import { create } from "xmlbuilder2";
|
|
8
7
|
//#region src/helpers/global.helper.ts
|
|
9
8
|
const version = version$1;
|
|
@@ -34,14 +33,50 @@ async function prepareData(domain, options) {
|
|
|
34
33
|
const ignore = prepareIgnored(options?.ignore, options?.outDir);
|
|
35
34
|
const changeFreq = prepareChangeFreq(options);
|
|
36
35
|
const pages = await fg(`${FOLDER}/**/*.html`, { ignore });
|
|
37
|
-
if (options
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (options?.additional) pages.push(...options.additional);
|
|
37
|
+
pages.sort();
|
|
38
|
+
const results = [];
|
|
39
|
+
for (const page of pages) {
|
|
40
|
+
const url = getUrl(page, domain, options);
|
|
41
|
+
const pathUrl = getUrl(page, "", options);
|
|
42
|
+
const path = pathUrl.startsWith("/") ? pathUrl : `/${pathUrl}`;
|
|
43
|
+
const defaultItem = {
|
|
44
|
+
loc: url,
|
|
45
|
+
page: url,
|
|
41
46
|
changeFreq,
|
|
42
|
-
|
|
47
|
+
changefreq: changeFreq,
|
|
48
|
+
lastMod: options?.resetTime ? (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : "",
|
|
49
|
+
lastmod: options?.resetTime ? (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : ""
|
|
43
50
|
};
|
|
44
|
-
|
|
51
|
+
let item = null;
|
|
52
|
+
if (options?.transform) {
|
|
53
|
+
const transformed = await options.transform(options, path);
|
|
54
|
+
if (transformed === null) item = null;
|
|
55
|
+
else item = transformed ? {
|
|
56
|
+
...defaultItem,
|
|
57
|
+
...transformed
|
|
58
|
+
} : defaultItem;
|
|
59
|
+
} else item = defaultItem;
|
|
60
|
+
if (item) {
|
|
61
|
+
if (!item.loc) item.loc = item.page;
|
|
62
|
+
if (!item.page) item.page = item.loc;
|
|
63
|
+
if (item.changefreq === void 0 && item.changeFreq !== void 0) item.changefreq = item.changeFreq;
|
|
64
|
+
if (item.changeFreq === void 0 && item.changefreq !== void 0) item.changeFreq = item.changefreq;
|
|
65
|
+
if (item.lastmod === void 0 && item.lastMod !== void 0) item.lastmod = item.lastMod;
|
|
66
|
+
if (item.lastMod === void 0 && item.lastmod !== void 0) item.lastMod = item.lastmod;
|
|
67
|
+
if (item.loc && !item.loc.startsWith("http")) {
|
|
68
|
+
const base = domain.endsWith("/") ? domain.slice(0, -1) : domain;
|
|
69
|
+
if (item.loc.startsWith("/")) if (item.loc === "/" && !options?.trailingSlashes) item.loc = base;
|
|
70
|
+
else item.loc = `${base}${item.loc}`;
|
|
71
|
+
else {
|
|
72
|
+
const slash = getSlash(domain);
|
|
73
|
+
item.loc = `${domain}${slash}${item.loc}`;
|
|
74
|
+
}
|
|
75
|
+
item.page = item.loc;
|
|
76
|
+
}
|
|
77
|
+
results.push(item);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
45
80
|
detectErrors({
|
|
46
81
|
folder: !fs.existsSync(FOLDER),
|
|
47
82
|
htmlFiles: !pages.length
|
|
@@ -54,10 +89,10 @@ const detectErrors = ({ folder, htmlFiles }, outDir = OUT_DIR) => {
|
|
|
54
89
|
else if (htmlFiles) console.error(cliColors.red, errorMsgHtmlFiles(outDir));
|
|
55
90
|
};
|
|
56
91
|
const checkPrerenderRoutes = async (pages, outDir, options) => {
|
|
57
|
-
if (fs.existsSync(
|
|
92
|
+
if (fs.existsSync(`${outDir}/_app`)) {
|
|
58
93
|
const hasOnlyRootOrFallback = pages.every((page) => {
|
|
59
|
-
const
|
|
60
|
-
return
|
|
94
|
+
const basename = page.split("/").pop();
|
|
95
|
+
return basename === "index.html" || basename === "fallback.html";
|
|
61
96
|
});
|
|
62
97
|
const hasNoAdditional = !options?.additional || options.additional.length === 0;
|
|
63
98
|
if (hasOnlyRootOrFallback && hasNoAdditional) console.warn(cliColors.yellow, ` ⚠️ Warning: Only the homepage or fallback page was found in '${outDir}/'.\n If your SvelteKit site has multiple routes, make sure you enabled prerendering for them.\n For SPA (Single Page Apps), you can add routes manually using the 'additional' option.`);
|
|
@@ -74,13 +109,22 @@ const writeSitemap = (items, options, domain) => {
|
|
|
74
109
|
}
|
|
75
110
|
};
|
|
76
111
|
const createFile = (items, options, outDir, chunkId) => {
|
|
77
|
-
const sitemap = createXml("urlset");
|
|
112
|
+
const sitemap = createXml("urlset", items.some((item) => item.alternateRefs && item.alternateRefs.length > 0));
|
|
78
113
|
addAttribution(sitemap, options);
|
|
79
114
|
for (const item of items) {
|
|
80
115
|
const page = sitemap.ele("url");
|
|
81
|
-
|
|
82
|
-
if (
|
|
83
|
-
|
|
116
|
+
const loc = item.loc || item.page;
|
|
117
|
+
if (loc) page.ele("loc").txt(loc);
|
|
118
|
+
const changefreq = item.changefreq || item.changeFreq;
|
|
119
|
+
if (changefreq) page.ele("changefreq").txt(changefreq);
|
|
120
|
+
const lastmod = item.lastmod || item.lastMod;
|
|
121
|
+
if (lastmod) page.ele("lastmod").txt(lastmod);
|
|
122
|
+
if (item.priority !== void 0 && item.priority !== null) page.ele("priority").txt(item.priority.toString());
|
|
123
|
+
if (item.alternateRefs && Array.isArray(item.alternateRefs)) for (const ref of item.alternateRefs) page.ele("xhtml:link", {
|
|
124
|
+
rel: "alternate",
|
|
125
|
+
hreflang: ref.hreflang,
|
|
126
|
+
href: ref.href
|
|
127
|
+
});
|
|
84
128
|
}
|
|
85
129
|
const xml = finishXml(sitemap);
|
|
86
130
|
const fileName = chunkId ? `sitemap-${chunkId}.xml` : "sitemap.xml";
|
|
@@ -120,11 +164,13 @@ const prepareChangeFreq = (options) => {
|
|
|
120
164
|
return result;
|
|
121
165
|
};
|
|
122
166
|
const getSlash = (domain) => domain.split("/").pop() ? "/" : "";
|
|
123
|
-
const createXml = (elementName) => {
|
|
167
|
+
const createXml = (elementName, hasAlternateRefs = false) => {
|
|
168
|
+
const attrs = { xmlns: "http://www.sitemaps.org/schemas/sitemap/0.9" };
|
|
169
|
+
if (hasAlternateRefs) attrs["xmlns:xhtml"] = "http://www.w3.org/1999/xhtml";
|
|
124
170
|
return create({
|
|
125
171
|
version: "1.0",
|
|
126
172
|
encoding: "UTF-8"
|
|
127
|
-
}).ele(elementName,
|
|
173
|
+
}).ele(elementName, attrs);
|
|
128
174
|
};
|
|
129
175
|
const finishXml = (sitemap) => {
|
|
130
176
|
return sitemap.end({ prettyPrint: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"global.helper.js","names":["pkg.version"],"sources":["../../src/helpers/global.helper.ts"],"sourcesContent":["import fg from 'fast-glob';\nimport fs from 'fs';\nimport path from 'path';\nimport { create } from 'xmlbuilder2';\nimport type { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { CHANGE_FREQ, CHUNK, OUT_DIR } from '../const.js';\nimport type { ChangeFreq, Options, OptionsSvelteSitemap, PagesJson } from './../dto/index.js';\nimport {\n cliColors,\n errorMsgFolder,\n errorMsgHtmlFiles,\n errorMsgWrite,\n successMsg\n} from './vars.helper.js';\n\nconst version = pkg.version;\n\nconst getUrl = (url: string, domain: string, options: Options) => {\n let slash: '' | '/' = getSlash(domain);\n\n let trimmed = url\n .split((options?.outDir ?? OUT_DIR) + '/')\n .pop()\n .replace('index.html', '');\n\n trimmed = removeHtml(trimmed);\n\n // Add all traling slashes\n if (options?.trailingSlashes) {\n trimmed = trimmed.length && !trimmed.endsWith('/') ? trimmed + '/' : trimmed;\n } else {\n trimmed = trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;\n slash = trimmed ? slash : '';\n }\n\n // URI-encode each path segment to handle special characters (e.g. spaces → %20).\n // Decode first to avoid double-encoding already percent-encoded segments.\n trimmed = trimmed\n .split('/')\n .map((segment) => {\n try {\n return encodeURIComponent(decodeURIComponent(segment));\n } catch {\n return encodeURIComponent(segment);\n }\n })\n .join('/');\n\n return `${domain}${slash}${trimmed}`;\n};\n\nexport const removeHtml = (fileName: string) => {\n if (fileName?.endsWith('.html')) {\n return fileName.slice(0, -5);\n }\n return fileName;\n};\n\nexport async function prepareData(domain: string, options?: Options): Promise<PagesJson[]> {\n const FOLDER = options?.outDir ?? OUT_DIR;\n\n const ignore = prepareIgnored(options?.ignore, options?.outDir);\n const changeFreq = prepareChangeFreq(options);\n const pages: string[] = await fg(`${FOLDER}/**/*.html`, { ignore });\n\n if (options.additional) pages.push(...options.additional);\n\n const results = pages.map((page) => {\n return {\n page: getUrl(page, domain, options),\n changeFreq: changeFreq,\n lastMod: options?.resetTime ? new Date().toISOString().split('T')[0] : ''\n };\n });\n\n detectErrors(\n {\n folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n },\n FOLDER\n );\n\n await checkPrerenderRoutes(pages, FOLDER, options);\n\n return results;\n}\n\nexport const detectErrors = (\n { folder, htmlFiles }: { folder: boolean; htmlFiles: boolean },\n outDir: string = OUT_DIR\n) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(outDir));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(outDir));\n }\n};\n\nexport const checkPrerenderRoutes = async (pages: string[], outDir: string, options?: Options) => {\n // Check if it's a SvelteKit build by checking for the '_app' directory in output folder\n const appDirExists = fs.existsSync(path.join(outDir, '_app'));\n\n if (appDirExists && pages.length > 0) {\n const hasOnlyRootOrFallback = pages.every((page) => {\n const relative = path.relative(outDir, page);\n return relative === 'index.html' || relative === 'fallback.html';\n });\n\n const hasNoAdditional = !options?.additional || options.additional.length === 0;\n\n if (hasOnlyRootOrFallback && hasNoAdditional) {\n console.warn(\n cliColors.yellow,\n ` ⚠️ Warning: Only the homepage or fallback page was found in '${outDir}/'.\\n` +\n ` If your SvelteKit site has multiple routes, make sure you enabled prerendering for them.\\n` +\n ` For SPA (Single Page Apps), you can add routes manually using the 'additional' option.`\n );\n }\n }\n};\n\nexport const writeSitemap = (items: PagesJson[], options: Options, domain: string): void => {\n const outDir = options?.outDir ?? OUT_DIR;\n\n if (items?.length <= CHUNK.maxSize) {\n createFile(items, options, outDir);\n } else {\n // If the number of pages is greater than the chunk size, then we split the sitemap into multiple files\n // and create an index file that links to all of them\n // https://support.google.com/webmasters/answer/183668?hl=en\n const numberOfChunks = Math.ceil(items.length / CHUNK.maxSize);\n\n console.log(\n cliColors.cyanAndBold,\n `> Oh, your site is huge! Writing sitemap in chunks of ${numberOfChunks} pages and its index sitemap.xml`\n );\n\n for (let i = 0; i < items.length; i += CHUNK.maxSize) {\n const chunk = items.slice(i, i + CHUNK.maxSize);\n createFile(chunk, options, outDir, i / CHUNK.maxSize + 1);\n }\n createIndexFile(numberOfChunks, outDir, options, domain);\n }\n};\n\nconst createFile = (\n items: PagesJson[],\n options: Options,\n outDir: string,\n chunkId?: number\n): void => {\n const sitemap = createXml('urlset');\n addAttribution(sitemap, options);\n\n for (const item of items) {\n const page = sitemap.ele('url');\n page.ele('loc').txt(item.page);\n if (item.changeFreq) {\n page.ele('changefreq').txt(item.changeFreq);\n }\n if (item.lastMod) {\n page.ele('lastmod').txt(item.lastMod);\n }\n }\n\n const xml = finishXml(sitemap);\n\n const fileName = chunkId ? `sitemap-${chunkId}.xml` : 'sitemap.xml';\n\n try {\n fs.writeFileSync(`${outDir}/${fileName}`, xml);\n console.log(cliColors.green, successMsg(outDir, fileName));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, fileName), e);\n }\n};\n\nconst createIndexFile = (\n numberOfChunks: number,\n outDir: string,\n options: Options,\n domain: string\n): void => {\n const FILENAME = 'sitemap.xml';\n const slash = getSlash(domain);\n\n const sitemap = createXml('sitemapindex');\n addAttribution(sitemap, options);\n\n for (let i = 1; i <= numberOfChunks; i++) {\n sitemap.ele('sitemap').ele('loc').txt(`${domain}${slash}sitemap-${i}.xml`);\n }\n\n const xml = finishXml(sitemap);\n\n try {\n fs.writeFileSync(`${outDir}/${FILENAME}`, xml);\n console.log(cliColors.green, successMsg(outDir, FILENAME));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, FILENAME), e);\n }\n};\n\nconst prepareIgnored = (\n ignored: string | string[],\n outDir: string = OUT_DIR\n): string[] | undefined => {\n let ignore: string[] | undefined;\n if (ignored) {\n ignore = Array.isArray(ignored) ? ignored : [ignored];\n ignore = ignore.map((ignoredPage) => `${outDir}/${ignoredPage}`);\n }\n return ignore;\n};\n\nconst prepareChangeFreq = (options: Options): ChangeFreq => {\n let result: ChangeFreq = null;\n\n if (options?.changeFreq) {\n if (CHANGE_FREQ.includes(options.changeFreq)) {\n result = options.changeFreq;\n } else {\n console.log(\n cliColors.red,\n ` × Option \\`--change-freq ${options.changeFreq}\\` is not a valid value. See docs: https://github.com/bartholomej/svelte-sitemap#options`\n );\n }\n }\n return result;\n};\n\nconst getSlash = (domain: string) => (domain.split('/').pop() ? '/' : '');\n\nconst createXml = (elementName: 'urlset' | 'sitemapindex'): XMLBuilder => {\n return create({ version: '1.0', encoding: 'UTF-8' }).ele(elementName, {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'\n });\n};\n\nconst finishXml = (sitemap: XMLBuilder): string => {\n return sitemap.end({ prettyPrint: true });\n};\n\nconst addAttribution = (sitemap: XMLBuilder, options: Options): void => {\n if (options?.attribution !== false) {\n sitemap.com(\n ` This file was automatically generated by https://github.com/bartholomej/svelte-sitemap v${version} `\n );\n }\n};\n"],"mappings":";;;;;;;;AAgBA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,MAAM;CAErC,IAAI,UAAU,IACX,OAAO,SAAS,UAAA,WAAqB,GAAG,CAAC,CACzC,IAAI,CAAC,CACL,QAAQ,cAAc,EAAE;CAE3B,UAAU,WAAW,OAAO;CAG5B,IAAI,SAAS,iBACX,UAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,UAAU,MAAM;MAChE;EACL,UAAU,QAAQ,SAAS,GAAG,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI;EACzD,QAAQ,UAAU,QAAQ;CAC5B;CAIA,UAAU,QACP,MAAM,GAAG,CAAC,CACV,KAAK,YAAY;EAChB,IAAI;GACF,OAAO,mBAAmB,mBAAmB,OAAO,CAAC;EACvD,QAAQ;GACN,OAAO,mBAAmB,OAAO;EACnC;CACF,CAAC,CAAC,CACD,KAAK,GAAG;CAEX,OAAO,GAAG,SAAS,QAAQ;AAC7B;AAEA,MAAa,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AS,gBAAgB,OAC3B,QAAQ,IACN,4FAA4F,QAAQ,EACtG;AAEJ"}
|
|
1
|
+
{"version":3,"file":"global.helper.js","names":["pkg.version"],"sources":["../../src/helpers/global.helper.ts"],"sourcesContent":["import fg from 'fast-glob';\nimport fs from 'fs';\nimport { create } from 'xmlbuilder2';\nimport type { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { CHANGE_FREQ, CHUNK, OUT_DIR } from '../const.js';\nimport type { ChangeFreq, Options, OptionsSvelteSitemap, PagesJson } from './../dto/index.js';\nimport {\n cliColors,\n errorMsgFolder,\n errorMsgHtmlFiles,\n errorMsgWrite,\n successMsg\n} from './vars.helper.js';\n\nconst version = pkg.version;\n\nconst getUrl = (url: string, domain: string, options: Options) => {\n let slash: '' | '/' = getSlash(domain);\n\n let trimmed = url\n .split((options?.outDir ?? OUT_DIR) + '/')\n .pop()\n .replace('index.html', '');\n\n trimmed = removeHtml(trimmed);\n\n // Add all traling slashes\n if (options?.trailingSlashes) {\n trimmed = trimmed.length && !trimmed.endsWith('/') ? trimmed + '/' : trimmed;\n } else {\n trimmed = trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;\n slash = trimmed ? slash : '';\n }\n\n // URI-encode each path segment to handle special characters (e.g. spaces → %20).\n // Decode first to avoid double-encoding already percent-encoded segments.\n trimmed = trimmed\n .split('/')\n .map((segment) => {\n try {\n return encodeURIComponent(decodeURIComponent(segment));\n } catch {\n return encodeURIComponent(segment);\n }\n })\n .join('/');\n\n return `${domain}${slash}${trimmed}`;\n};\n\nexport const removeHtml = (fileName: string) => {\n if (fileName?.endsWith('.html')) {\n return fileName.slice(0, -5);\n }\n return fileName;\n};\n\nexport async function prepareData(domain: string, options?: Options): Promise<PagesJson[]> {\n const FOLDER = options?.outDir ?? OUT_DIR;\n\n const ignore = prepareIgnored(options?.ignore, options?.outDir);\n const changeFreq = prepareChangeFreq(options);\n const pages: string[] = await fg(`${FOLDER}/**/*.html`, { ignore });\n\n if (options?.additional) pages.push(...options.additional);\n\n pages.sort();\n\n const results: PagesJson[] = [];\n\n for (const page of pages) {\n const url = getUrl(page, domain, options);\n const pathUrl = getUrl(page, '', options);\n const path = pathUrl.startsWith('/') ? pathUrl : `/${pathUrl}`;\n\n const defaultItem: PagesJson = {\n loc: url,\n page: url,\n changeFreq: changeFreq,\n changefreq: changeFreq,\n lastMod: options?.resetTime ? new Date().toISOString().split('T')[0] : '',\n lastmod: options?.resetTime ? new Date().toISOString().split('T')[0] : ''\n };\n\n let item: PagesJson | null = null;\n\n if (options?.transform) {\n const transformed = await options.transform(options as OptionsSvelteSitemap, path);\n if (transformed === null) {\n item = null;\n } else {\n item = transformed ? { ...defaultItem, ...transformed } : defaultItem;\n }\n } else {\n item = defaultItem;\n }\n\n if (item) {\n if (!item.loc) item.loc = item.page;\n if (!item.page) item.page = item.loc;\n\n if (item.changefreq === undefined && item.changeFreq !== undefined)\n item.changefreq = item.changeFreq;\n if (item.changeFreq === undefined && item.changefreq !== undefined)\n item.changeFreq = item.changefreq;\n\n if (item.lastmod === undefined && item.lastMod !== undefined) item.lastmod = item.lastMod;\n if (item.lastMod === undefined && item.lastmod !== undefined) item.lastMod = item.lastmod;\n\n if (item.loc && !item.loc.startsWith('http')) {\n const base = domain.endsWith('/') ? domain.slice(0, -1) : domain;\n if (item.loc.startsWith('/')) {\n if (item.loc === '/' && !options?.trailingSlashes) {\n item.loc = base;\n } else {\n item.loc = `${base}${item.loc}`;\n }\n } else {\n const slash = getSlash(domain);\n item.loc = `${domain}${slash}${item.loc}`;\n }\n item.page = item.loc;\n }\n\n results.push(item);\n }\n }\n\n detectErrors(\n {\n folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n },\n FOLDER\n );\n\n await checkPrerenderRoutes(pages, FOLDER, options);\n\n return results;\n}\n\nexport const detectErrors = (\n { folder, htmlFiles }: { folder: boolean; htmlFiles: boolean },\n outDir: string = OUT_DIR\n) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(outDir));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(outDir));\n }\n};\n\nexport const checkPrerenderRoutes = async (pages: string[], outDir: string, options?: Options) => {\n // Check if it's a SvelteKit build by checking for the '_app' directory in output folder\n const appDirExists = fs.existsSync(`${outDir}/_app`);\n\n if (appDirExists) {\n const hasOnlyRootOrFallback = pages.every((page) => {\n const basename = page.split('/').pop();\n return basename === 'index.html' || basename === 'fallback.html';\n });\n\n const hasNoAdditional = !options?.additional || options.additional.length === 0;\n\n if (hasOnlyRootOrFallback && hasNoAdditional) {\n console.warn(\n cliColors.yellow,\n ` ⚠️ Warning: Only the homepage or fallback page was found in '${outDir}/'.\\n` +\n ` If your SvelteKit site has multiple routes, make sure you enabled prerendering for them.\\n` +\n ` For SPA (Single Page Apps), you can add routes manually using the 'additional' option.`\n );\n }\n }\n};\n\nexport const writeSitemap = (items: PagesJson[], options: Options, domain: string): void => {\n const outDir = options?.outDir ?? OUT_DIR;\n\n if (items?.length <= CHUNK.maxSize) {\n createFile(items, options, outDir);\n } else {\n // If the number of pages is greater than the chunk size, then we split the sitemap into multiple files\n // and create an index file that links to all of them\n // https://support.google.com/webmasters/answer/183668?hl=en\n const numberOfChunks = Math.ceil(items.length / CHUNK.maxSize);\n\n console.log(\n cliColors.cyanAndBold,\n `> Oh, your site is huge! Writing sitemap in chunks of ${numberOfChunks} pages and its index sitemap.xml`\n );\n\n for (let i = 0; i < items.length; i += CHUNK.maxSize) {\n const chunk = items.slice(i, i + CHUNK.maxSize);\n createFile(chunk, options, outDir, i / CHUNK.maxSize + 1);\n }\n createIndexFile(numberOfChunks, outDir, options, domain);\n }\n};\n\nconst createFile = (\n items: PagesJson[],\n options: Options,\n outDir: string,\n chunkId?: number\n): void => {\n const hasAlternateRefs = items.some(\n (item) => item.alternateRefs && item.alternateRefs.length > 0\n );\n const sitemap = createXml('urlset', hasAlternateRefs);\n addAttribution(sitemap, options);\n\n for (const item of items) {\n const page = sitemap.ele('url');\n // fallbacks for backward compatibility\n const loc = item.loc || item.page;\n if (loc) {\n page.ele('loc').txt(loc);\n }\n\n const changefreq = item.changefreq || item.changeFreq;\n if (changefreq) {\n page.ele('changefreq').txt(changefreq);\n }\n\n const lastmod = item.lastmod || item.lastMod;\n if (lastmod) {\n page.ele('lastmod').txt(lastmod);\n }\n\n if (item.priority !== undefined && item.priority !== null) {\n page.ele('priority').txt(item.priority.toString());\n }\n\n if (item.alternateRefs && Array.isArray(item.alternateRefs)) {\n for (const ref of item.alternateRefs) {\n page.ele('xhtml:link', {\n rel: 'alternate',\n hreflang: ref.hreflang,\n href: ref.href\n });\n }\n }\n }\n\n const xml = finishXml(sitemap);\n\n const fileName = chunkId ? `sitemap-${chunkId}.xml` : 'sitemap.xml';\n\n try {\n fs.writeFileSync(`${outDir}/${fileName}`, xml);\n console.log(cliColors.green, successMsg(outDir, fileName));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, fileName), e);\n }\n};\n\nconst createIndexFile = (\n numberOfChunks: number,\n outDir: string,\n options: Options,\n domain: string\n): void => {\n const FILENAME = 'sitemap.xml';\n const slash = getSlash(domain);\n\n const sitemap = createXml('sitemapindex');\n addAttribution(sitemap, options);\n\n for (let i = 1; i <= numberOfChunks; i++) {\n sitemap.ele('sitemap').ele('loc').txt(`${domain}${slash}sitemap-${i}.xml`);\n }\n\n const xml = finishXml(sitemap);\n\n try {\n fs.writeFileSync(`${outDir}/${FILENAME}`, xml);\n console.log(cliColors.green, successMsg(outDir, FILENAME));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, FILENAME), e);\n }\n};\n\nconst prepareIgnored = (\n ignored: string | string[],\n outDir: string = OUT_DIR\n): string[] | undefined => {\n let ignore: string[] | undefined;\n if (ignored) {\n ignore = Array.isArray(ignored) ? ignored : [ignored];\n ignore = ignore.map((ignoredPage) => `${outDir}/${ignoredPage}`);\n }\n return ignore;\n};\n\nconst prepareChangeFreq = (options: Options): ChangeFreq => {\n let result: ChangeFreq = null;\n\n if (options?.changeFreq) {\n if (CHANGE_FREQ.includes(options.changeFreq)) {\n result = options.changeFreq;\n } else {\n console.log(\n cliColors.red,\n ` × Option \\`--change-freq ${options.changeFreq}\\` is not a valid value. See docs: https://github.com/bartholomej/svelte-sitemap#options`\n );\n }\n }\n return result;\n};\n\nconst getSlash = (domain: string) => (domain.split('/').pop() ? '/' : '');\n\nconst createXml = (\n elementName: 'urlset' | 'sitemapindex',\n hasAlternateRefs = false\n): XMLBuilder => {\n const attrs: Record<string, string> = {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'\n };\n if (hasAlternateRefs) {\n attrs['xmlns:xhtml'] = 'http://www.w3.org/1999/xhtml';\n }\n return create({ version: '1.0', encoding: 'UTF-8' }).ele(elementName, attrs);\n};\n\nconst finishXml = (sitemap: XMLBuilder): string => {\n return sitemap.end({ prettyPrint: true });\n};\n\nconst addAttribution = (sitemap: XMLBuilder, options: Options): void => {\n if (options?.attribution !== false) {\n sitemap.com(\n ` This file was automatically generated by https://github.com/bartholomej/svelte-sitemap v${version} `\n );\n }\n};\n"],"mappings":";;;;;;;AAeA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,MAAM;CAErC,IAAI,UAAU,IACX,OAAO,SAAS,UAAA,WAAqB,GAAG,CAAC,CACzC,IAAI,CAAC,CACL,QAAQ,cAAc,EAAE;CAE3B,UAAU,WAAW,OAAO;CAG5B,IAAI,SAAS,iBACX,UAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,GAAG,IAAI,UAAU,MAAM;MAChE;EACL,UAAU,QAAQ,SAAS,GAAG,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI;EACzD,QAAQ,UAAU,QAAQ;CAC5B;CAIA,UAAU,QACP,MAAM,GAAG,CAAC,CACV,KAAK,YAAY;EAChB,IAAI;GAC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;EACX,SAAS,MAAM,QAAQ,OAAO,IAAI,UAAU,CAAC,OAAO;EACpD,SAAS,OAAO,KAAK,gBAAgB,GAAG,OAAO,GAAG,aAAa;CACjE;CACA,OAAO;AACT;AAEA,MAAM,qBAAqB,YAAiC;CAC1D,IAAI,SAAqB;CAEzB,IAAI,SAAS,YACX,IAAI,YAAY,SAAS,QAAQ,UAAU,GACzC,SAAS,QAAQ;MAEjB,QAAQ,IACN,UAAU,KACV,8BAA8B,QAAQ,WAAW,yFACnD;CAGJ,OAAO;AACT;AAEA,MAAM,YAAY,WAAoB,OAAO,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,MAAM;AAEtE,MAAM,aACJ,aACA,mBAAmB,UACJ;CACf,MAAM,QAAgC,EACpC,OAAO,8CACT;CACA,IAAI,kBACF,MAAM,iBAAiB;CAEzB,OAAO,OAAO;EAAE,SAAS;EAAO,UAAU;CAAQ,CAAC,CAAC,CAAC,IAAI,aAAa,KAAK;AAC7E;AAEA,MAAM,aAAa,YAAgC;CACjD,OAAO,QAAQ,IAAI,EAAE,aAAa,KAAK,CAAC;AAC1C;AAEA,MAAM,kBAAkB,SAAqB,YAA2B;CACtE,IAAI,SAAS,gBAAgB,OAC3B,QAAQ,IACN,4FAA4F,QAAQ,EACtG;AAEJ"}
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IntegrationMethod } from "./const.js";
|
|
2
|
-
import { Arguments, ChangeFreq, Options, OptionsSvelteSitemap, PagesJson } from "./dto/global.interface.js";
|
|
2
|
+
import { Arguments, ChangeFreq, Options, OptionsSvelteSitemap, PagesJson, SitemapField, SitemapFieldAlternateRef } from "./dto/global.interface.js";
|
|
3
3
|
import { svelteSitemap } from "./vite.js";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
declare const printIntro: (method?: IntegrationMethod) => void;
|
|
7
7
|
declare const createSitemap: (options: OptionsSvelteSitemap, method?: IntegrationMethod) => Promise<void>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { type Arguments, type ChangeFreq, type IntegrationMethod, type Options, type OptionsSvelteSitemap, type PagesJson, createSitemap, printIntro, svelteSitemap };
|
|
9
|
+
export { type Arguments, type ChangeFreq, type IntegrationMethod, type Options, type OptionsSvelteSitemap, type PagesJson, type SitemapField, type SitemapFieldAlternateRef, createSitemap, printIntro, svelteSitemap };
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/package.js
CHANGED
package/package.json
CHANGED