svelte-sitemap 3.2.0 → 3.3.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,9 +26,34 @@ 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
+ We recommend using the **Vite plugin** (Method 1) as it integrates directly into your build pipeline. For other setups, you can use a config file, CLI, or the JS API.
30
30
 
31
- ### Method 1: Config file (recommended)
31
+ ### Method 1: Vite plugin (Recommended)
32
+
33
+ If you're using SvelteKit with Vite (which is the default), you can integrate the sitemap generation directly into the Vite build pipeline.
34
+
35
+ Add the plugin to your `vite.config.ts`:
36
+
37
+ ```typescript
38
+ // vite.config.ts
39
+ import { sveltekit } from '@sveltejs/kit/vite';
40
+ import { svelteSitemap } from 'svelte-sitemap/vite'; // <-- Add svelte-sitemap vite plugin
41
+ import { defineConfig } from 'vite';
42
+
43
+ export default defineConfig({
44
+ plugins: [
45
+ sveltekit(),
46
+ svelteSitemap({ domain: 'https://example.com' }) // <-- Configure the plugin with your options
47
+ ]
48
+ });
49
+ ```
50
+
51
+ The sitemap is generated automatically at the end of every `vite build`. All [options](#%EF%B8%8F-options) are supported.
52
+
53
+ ---
54
+
55
+ <details>
56
+ <summary><b>✨ Method 2: Config file (Alternative)</b></summary>
32
57
 
33
58
  Create a config file `svelte-sitemap.config.ts` in the root of your project:
34
59
 
@@ -57,9 +82,10 @@ Then add `svelte-sitemap` as a `postbuild` script in `package.json`:
57
82
 
58
83
  That's it. After every `build`, the sitemap is automatically generated in your `build/` folder.
59
84
 
60
- ---
85
+ </details>
61
86
 
62
- ### ⌨️ Method 2: CLI (legacy)
87
+ <details>
88
+ <summary><b>⌨️ Method 3: CLI (legacy)</b></summary>
63
89
 
64
90
  Pass options directly as CLI flags — no config file needed:
65
91
 
@@ -73,9 +99,10 @@ Pass options directly as CLI flags — no config file needed:
73
99
 
74
100
  See all available flags in the [Options](#%EF%B8%8F-options) table below.
75
101
 
76
- ---
102
+ </details>
77
103
 
78
- ### 🔧 Method 3: JavaScript / TypeScript API
104
+ <details>
105
+ <summary><b>🔧 Method 4: JavaScript / TypeScript API</b></summary>
79
106
 
80
107
  Sometimes it's useful to call the script directly from code:
81
108
 
@@ -92,6 +119,8 @@ Run your script:
92
119
  node my-script.js
93
120
  ```
94
121
 
122
+ </details>
123
+
95
124
  ---
96
125
 
97
126
  ## ⚙️ Options
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "3.2.0";
2
+ var version = "3.3.0-next.1";
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.2.0",
3
+ "version": "3.3.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
18
  "jiti": "^2.7.0",
@@ -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;CACnE,OAAO;EACL,MAAM;EACN,OAAO;EACP,aAAa,YAAY;GACvB,MAAM,cAAc,OAAO;EAC7B;CACF;AACF"}