You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> Use this library as a `postbuild` hook in your `package.json` file.
23
+
### Config file method (recommended)
24
+
25
+
Create config file `svelte-sitemap.cjs` in the root of your project:
26
+
27
+
`svelte-sitemap.cjs`
28
+
29
+
```js
30
+
module.exports= {
31
+
domain:'https://www.example.com'
32
+
// ...more options
33
+
};
34
+
```
35
+
36
+
Add `svelte-sitemap` as your postbuild script in `package.json` file:
37
+
38
+
`package.json`
39
+
40
+
```json
41
+
{
42
+
"postbuild": "npx svelte-sitemap"
43
+
}
44
+
```
45
+
46
+
### Alternative 1: CLI method
24
47
25
48
File: `package.json`
26
49
@@ -35,7 +58,7 @@ File: `package.json`
35
58
36
59
It scans your routes in `build/` folder and generates `build/sitemap.xml` file.
37
60
38
-
### Alternative usage: TypeScript or JavaScript method
61
+
### Alternative 2: TypeScript or JavaScript method
39
62
40
63
> Sometimes it can be useful to call the script directly from JavaScript or TypeScript. Of course there is also this option, but in most cases you will need the [CLI method](#cli-method-recommended) as a postbuild hook.
And now you can run your script like this: `node my-script.js`
51
74
75
+
## Example
76
+
77
+
Use this library as a `postbuild` hook in your `package.json` with config file `svelte-sitemap.cjs` in your project root.
78
+
79
+
File: `package.json`
80
+
81
+
```json
82
+
{
83
+
"name": "my-project",
84
+
"scripts": {
85
+
"postbuild": "npx svelte-sitemap"
86
+
}
87
+
}
88
+
```
89
+
90
+
File: `svelte-sitemap.cjs`
91
+
92
+
```typescript
93
+
module.exports= {
94
+
domain: 'https://www.example.com',
95
+
trailingSlashes: true
96
+
};
97
+
```
98
+
52
99
## ⚙️ Options
53
100
54
101
| Option | Description | Default | Example |
@@ -136,6 +183,7 @@ yarn demo
136
183
- svelte-sitemap is workaround for [this official SvelteKit issue](https://github.com/sveltejs/kit/issues/1142)
137
184
- Brand new version is inspired by [Richard's article](https://r-bt.com/learning/sveltekit-sitemap/)
138
185
- Thanks to [@auderer](https://github.com/auderer) because [his issue](https://github.com/bartholomej/svelte-sitemap/issues/1) changed the direction of this library
186
+
- Config files inspired by [next-sitemap](https://github.com/iamvishnusankar/next-sitemap)
0 commit comments