svelte-sitemap 3.0.1 → 3.2.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 CHANGED
@@ -9,7 +9,7 @@
9
9
  ---
10
10
 
11
11
  - ➡️ Designed for SvelteKit `adapter-static` with `prerender` option (SSG)
12
- - 🔷 TypeScript, JavaScript, CLI version
12
+ - 🔷 TypeScript, JavaScript, CLI and **Vite plugin** version
13
13
  - 🔧 Useful [options](#%EF%B8%8F-options) for customizing your sitemap
14
14
  - 📡 [Ping](#-ping-google-search-console) Google Search Console after deploy
15
15
  - 🗂️ Support for [sitemap index](https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps) for large sites (50K+ pages)
@@ -26,7 +26,7 @@ npm install svelte-sitemap --save-dev
26
26
 
27
27
  ## 🚀 Usage
28
28
 
29
- > There are three ways to use this library. Pick the one that suits you best.
29
+ > There are four ways to use this library. Pick the one that suits you best.
30
30
 
31
31
  ### ✨ Method 1: Config file (recommended)
32
32
 
@@ -94,6 +94,27 @@ node my-script.js
94
94
 
95
95
  ---
96
96
 
97
+ ### ⚡ Method 4: Vite plugin
98
+
99
+ If you're using SvelteKit with Vite (which is the default), you can integrate the sitemap generation directly into the Vite build pipeline — no extra `postbuild` script needed.
100
+
101
+ Add the plugin to your `vite.config.ts`:
102
+
103
+ ```typescript
104
+ // vite.config.ts
105
+ import { sveltekit } from '@sveltejs/kit/vite';
106
+ import { svelteKitSitemap } from 'svelte-sitemap/vite';
107
+ import { defineConfig } from 'vite';
108
+
109
+ export default defineConfig({
110
+ plugins: [sveltekit(), svelteKitSitemap({ domain: 'https://example.com' })]
111
+ });
112
+ ```
113
+
114
+ The sitemap is generated automatically at the end of every `vite build`. All [options](#%EF%B8%8F-options) are supported.
115
+
116
+ ---
117
+
97
118
  ## ⚙️ Options
98
119
 
99
120
  Options are defined as **config file keys** (camelCase). Use it in your `svelte-sitemap.config.ts` file.
@@ -15,6 +15,13 @@ const getUrl = (url, domain, options) => {
15
15
  trimmed = trimmed.endsWith("/") ? trimmed.slice(0, -1) : trimmed;
16
16
  slash = trimmed ? slash : "";
17
17
  }
18
+ trimmed = trimmed.split("/").map((segment) => {
19
+ try {
20
+ return encodeURIComponent(decodeURIComponent(segment));
21
+ } catch {
22
+ return encodeURIComponent(segment);
23
+ }
24
+ }).join("/");
18
25
  return `${domain}${slash}${trimmed}`;
19
26
  };
20
27
  const removeHtml = (fileName) => {
@@ -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 { 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 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 folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n });\n\n return results;\n}\n\nexport const detectErrors = ({ folder, htmlFiles }: { folder: boolean; htmlFiles: boolean }) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(OUT_DIR));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(OUT_DIR));\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":";;;;;;;AAeA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,OAAO;CAEtC,IAAI,UAAU,IACX,OAAO,SAAS,UAAA,WAAqB,IAAI,CACzC,KAAK,CACL,QAAQ,cAAc,GAAG;AAE5B,WAAU,WAAW,QAAQ;AAG7B,KAAI,SAAS,gBACX,WAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,UAAU,MAAM;MAChE;AACL,YAAU,QAAQ,SAAS,IAAI,GAAG,QAAQ,MAAM,GAAG,GAAG,GAAG;AACzD,UAAQ,UAAU,QAAQ;;AAE5B,QAAO,GAAG,SAAS,QAAQ;;AAG7B,MAAa,cAAc,aAAqB;AAC9C,KAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO,SAAS,MAAM,GAAG,GAAG;AAE9B,QAAO;;AAGT,eAAsB,YAAY,QAAgB,SAAyC;CACzF,MAAM,SAAS,SAAS,UAAA;CAExB,MAAM,SAAS,eAAe,SAAS,QAAQ,SAAS,OAAO;CAC/D,MAAM,aAAa,kBAAkB,QAAQ;CAC7C,MAAM,QAAkB,MAAM,GAAG,GAAG,OAAO,aAAa,EAAE,QAAQ,CAAC;AAEnE,KAAI,QAAQ,WAAY,OAAM,KAAK,GAAG,QAAQ,WAAW;CAEzD,MAAM,UAAU,MAAM,KAAK,SAAS;AAClC,SAAO;GACL,MAAM,OAAO,MAAM,QAAQ,QAAQ;GACvB;GACZ,SAAS,SAAS,6BAAY,IAAI,MAAM,EAAC,aAAa,CAAC,MAAM,IAAI,CAAC,KAAK;GACxE;GACD;AAEF,cAAa;EACX,QAAQ,CAAC,GAAG,WAAW,OAAO;EAC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G3C,MAAM,kBAAkB,SAAqB,YAA2B;AACtE,KAAI,SAAS,gBAAgB,MAC3B,SAAQ,IACN,4FAA4F,QAAQ,GACrG"}
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 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 folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n });\n\n return results;\n}\n\nexport const detectErrors = ({ folder, htmlFiles }: { folder: boolean; htmlFiles: boolean }) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(OUT_DIR));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(OUT_DIR));\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":";;;;;;;AAeA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,OAAO;CAEtC,IAAI,UAAU,IACX,OAAO,SAAS,UAAA,WAAqB,IAAI,CACzC,KAAK,CACL,QAAQ,cAAc,GAAG;AAE5B,WAAU,WAAW,QAAQ;AAG7B,KAAI,SAAS,gBACX,WAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,UAAU,MAAM;MAChE;AACL,YAAU,QAAQ,SAAS,IAAI,GAAG,QAAQ,MAAM,GAAG,GAAG,GAAG;AACzD,UAAQ,UAAU,QAAQ;;AAK5B,WAAU,QACP,MAAM,IAAI,CACV,KAAK,YAAY;AAChB,MAAI;AACF,UAAO,mBAAmB,mBAAmB,QAAQ,CAAC;UAChD;AACN,UAAO,mBAAmB,QAAQ;;GAEpC,CACD,KAAK,IAAI;AAEZ,QAAO,GAAG,SAAS,QAAQ;;AAG7B,MAAa,cAAc,aAAqB;AAC9C,KAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO,SAAS,MAAM,GAAG,GAAG;AAE9B,QAAO;;AAGT,eAAsB,YAAY,QAAgB,SAAyC;CACzF,MAAM,SAAS,SAAS,UAAA;CAExB,MAAM,SAAS,eAAe,SAAS,QAAQ,SAAS,OAAO;CAC/D,MAAM,aAAa,kBAAkB,QAAQ;CAC7C,MAAM,QAAkB,MAAM,GAAG,GAAG,OAAO,aAAa,EAAE,QAAQ,CAAC;AAEnE,KAAI,QAAQ,WAAY,OAAM,KAAK,GAAG,QAAQ,WAAW;CAEzD,MAAM,UAAU,MAAM,KAAK,SAAS;AAClC,SAAO;GACL,MAAM,OAAO,MAAM,QAAQ,QAAQ;GACvB;GACZ,SAA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AS,CAAC,CAAC,IAAI,aAAa,EACpE,OAAO,+CACR,CAAC;;AAGJ,MAAM,aAAa,YAAgC;AACjD,QAAO,QAAQ,IAAI,EAAE,aAAa,MAAM,CAAC;;AAG3C,MAAM,kBAAkB,SAAqB,YAA2B;AACtE,KAAI,SAAS,gBAAgB,MAC3B,SAAQ,IACN,4FAA4F,QAAQ,GACrG"}
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.0.1";
2
+ var version = "3.2.0-next.0";
3
3
  //#endregion
4
4
  export { version };
5
5
 
package/package.json CHANGED
@@ -1,10 +1,18 @@
1
1
  {
2
2
  "name": "svelte-sitemap",
3
- "version": "3.0.1",
3
+ "version": "3.2.0-next.0",
4
4
  "type": "module",
5
5
  "description": "Small helper which scans your Svelte routes folder and generates static sitemap.xml",
6
6
  "author": "BART! <bart@bartweb.cz>",
7
7
  "bin": "cli.js",
8
+ "peerDependencies": {
9
+ "vite": ">=5.0.0"
10
+ },
11
+ "peerDependenciesMeta": {
12
+ "vite": {
13
+ "optional": true
14
+ }
15
+ },
8
16
  "dependencies": {
9
17
  "fast-glob": "^3.3.3",
10
18
  "jiti": "^2.6.1",
@@ -62,6 +70,7 @@
62
70
  "exports": {
63
71
  ".": "./index.js",
64
72
  "./cli": "./cli.js",
73
+ "./vite": "./vite.js",
65
74
  "./package.json": "./package.json"
66
75
  }
67
76
  }
package/vite.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { OptionsSvelteSitemap } from "./dto/global.interface.js";
2
+ import { Plugin } from "vite";
3
+
4
+ //#region src/vite.d.ts
5
+ declare function svelteKitSitemap(options: OptionsSvelteSitemap): Plugin;
6
+ //#endregion
7
+ export { svelteKitSitemap };
8
+ //# sourceMappingURL=vite.d.ts.map
package/vite.js ADDED
@@ -0,0 +1,15 @@
1
+ import { createSitemap } from "./index.js";
2
+ //#region src/vite.ts
3
+ function svelteKitSitemap(options) {
4
+ return {
5
+ name: "svelte-sitemap",
6
+ apply: "build",
7
+ closeBundle: async () => {
8
+ await createSitemap(options);
9
+ }
10
+ };
11
+ }
12
+ //#endregion
13
+ export { svelteKitSitemap };
14
+
15
+ //# sourceMappingURL=vite.js.map
package/vite.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import type { Plugin } from 'vite';\nimport type { OptionsSvelteSitemap } from './dto/index.js';\nimport { createSitemap } from './index.js';\n\nexport function svelteKitSitemap(options: OptionsSvelteSitemap): Plugin {\n return {\n name: 'svelte-sitemap',\n apply: 'build',\n closeBundle: async () => {\n await createSitemap(options);\n }\n };\n}\n"],"mappings":";;AAIA,SAAgB,iBAAiB,SAAuC;AACtE,QAAO;EACL,MAAM;EACN,OAAO;EACP,aAAa,YAAY;AACvB,SAAM,cAAc,QAAQ;;EAE/B"}