svelte-sitemap 3.1.0 → 3.2.0-next.1

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,30 @@ 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 { svelteSitemap } from 'svelte-sitemap/vite'; // <-- Add svelte-sitemap vite plugin
107
+ import { defineConfig } from 'vite';
108
+
109
+ export default defineConfig({
110
+ plugins: [
111
+ sveltekit(),
112
+ svelteSitemap({ domain: 'https://example.com' }) // <-- Configure the plugin with your options
113
+ ]
114
+ });
115
+ ```
116
+
117
+ The sitemap is generated automatically at the end of every `vite build`. All [options](#%EF%B8%8F-options) are supported.
118
+
119
+ ---
120
+
97
121
  ## ⚙️ Options
98
122
 
99
123
  Options are defined as **config file keys** (camelCase). Use it in your `svelte-sitemap.config.ts` file.
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.1.0";
2
+ var version = "3.2.0-next.1";
3
3
  //#endregion
4
4
  export { version };
5
5
 
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "svelte-sitemap",
3
- "version": "3.1.0",
3
+ "version": "3.2.0-next.1",
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
- "jiti": "^2.6.1",
18
+ "jiti": "^2.7.0",
11
19
  "minimist": "^1.2.8",
12
20
  "xmlbuilder2": "^4.0.3"
13
21
  },
@@ -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 svelteSitemap(options: OptionsSvelteSitemap): Plugin;
6
+ //#endregion
7
+ export { svelteSitemap };
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 svelteSitemap(options) {
4
+ return {
5
+ name: "svelte-sitemap",
6
+ apply: "build",
7
+ closeBundle: async () => {
8
+ await createSitemap(options);
9
+ }
10
+ };
11
+ }
12
+ //#endregion
13
+ export { svelteSitemap };
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 svelteSitemap(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,cAAc,SAAuC;AACnE,QAAO;EACL,MAAM;EACN,OAAO;EACP,aAAa,YAAY;AACvB,SAAM,cAAc,QAAQ;;EAE/B"}