svelte-sitemap 2.5.0 → 2.5.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 +62 -54
- package/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,38 +6,40 @@
|
|
|
6
6
|
|
|
7
7
|
> Small helper which scans your Svelte routes and generates _sitemap.xml_
|
|
8
8
|
>
|
|
9
|
-
> - Designed for Svelte `adapter-static` with `prerender` option
|
|
9
|
+
> - Designed for Svelte `adapter-static` with `prerender` option (SSG)
|
|
10
10
|
> - TypeScript, JavaScript, CLI version
|
|
11
11
|
> - Useful options
|
|
12
12
|
> - Workaround for [this official SvelteKit issue](https://github.com/sveltejs/kit/issues/1142)
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
16
|
-
via `yarn` or `npm`
|
|
17
|
-
|
|
18
16
|
```bash
|
|
19
|
-
|
|
20
|
-
#
|
|
17
|
+
npm install svelte-sitemap --save-dev
|
|
18
|
+
# yarn add svelte-sitemap --dev
|
|
21
19
|
```
|
|
22
20
|
|
|
23
21
|
## Usage
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Run in your project root folder to see how it works.
|
|
23
|
+
> Use this library as a `postbuild` hook in your `package.json` file.
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
File: `package.json`
|
|
30
26
|
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"name": "my-awesome-project",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"postbuild": "npx svelte-sitemap --domain https://myawesomedomain.com"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
It scans your routes in `build/` folder and generates `build/sitemap.xml` file
|
|
36
|
+
It scans your routes in `build/` folder and generates `build/sitemap.xml` file.
|
|
37
|
+
|
|
38
|
+
### Alternative usage: TypeScript or JavaScript method
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
> 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.
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
File `my-script.js`:
|
|
41
43
|
|
|
42
44
|
```typescript
|
|
43
45
|
import { createSitemap } from 'svelte-sitemap/src/index.js';
|
|
@@ -47,36 +49,23 @@ createSitemap('https://example.com', { debug: true });
|
|
|
47
49
|
|
|
48
50
|
And now you can run your script like this: `node my-script.js`
|
|
49
51
|
|
|
50
|
-
## Example
|
|
51
|
-
|
|
52
|
-
Highly recommended to use as `postbuild` hook in your `package.json`
|
|
53
|
-
|
|
54
|
-
```json
|
|
55
|
-
{
|
|
56
|
-
"name": "my-project",
|
|
57
|
-
"scripts": {
|
|
58
|
-
"postbuild": "npx svelte-sitemap --domain https://mydomain.com"
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
52
|
## ⚙️ Options
|
|
64
53
|
|
|
65
|
-
| Option
|
|
66
|
-
|
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
54
|
+
| Option | Description | Default | Example |
|
|
55
|
+
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------- |
|
|
56
|
+
| `--domain`, `-d` | Use your domain **[required]** | - | `-d https://mydomain.com` |
|
|
57
|
+
| `--out-dir`, `-o` | Set custom build folder | `build` | `-o dist` |
|
|
58
|
+
| `--ignore`, `-i` | Ignore files or folders | [] | `-i '**/admin/**' -i 'my-secret-page'` |
|
|
59
|
+
| `--trailing-slashes`, `-t` | Add trailing slashes | false | `--trailing-slashes` |
|
|
60
|
+
| `--reset-time`, `-r` | Set lastModified time to now | false | `-r` |
|
|
61
|
+
| `--change-freq`, `-c` | Set change frequency [Option](https://github.com/bartholomej/svelte-sitemap/blob/master/src/interfaces/global.interface.ts#L22) | - | `--change-freq daily` |
|
|
62
|
+
| `--help`, `-h` | Display this usage info | - | `-v` |
|
|
63
|
+
| `--version`, `-v` | Show version | - | `-h` |
|
|
64
|
+
| `--debug` | Show some useful logs | - | `--debug` |
|
|
76
65
|
|
|
77
66
|
## 🙋 FAQ
|
|
78
67
|
|
|
79
|
-
|
|
68
|
+
### How to exclude directory?
|
|
80
69
|
|
|
81
70
|
> Let's say we want to ignore all `admin` folders and subfolders + just one exact page `pages/my-secret-page`
|
|
82
71
|
|
|
@@ -84,6 +73,39 @@ Highly recommended to use as `postbuild` hook in your `package.json`
|
|
|
84
73
|
npx svelte-sitemap --domain https://www.example.com --ignore 'pages/my-secret-page' --ignore '**/admin/**'
|
|
85
74
|
```
|
|
86
75
|
|
|
76
|
+
### Ping Google Search Console
|
|
77
|
+
|
|
78
|
+
> Every time I deploy a new version, I want to inform Google that there is a new update.
|
|
79
|
+
|
|
80
|
+
See this [discussion](https://github.com/bartholomej/svelte-sitemap/issues/23) with very useful tips.
|
|
81
|
+
|
|
82
|
+
### Error: Missing folder
|
|
83
|
+
|
|
84
|
+
> × Folder 'build/' doesn't exist. Make sure you are using this library as 'postbuild' so 'build/' folder was successfully created before running this script.
|
|
85
|
+
|
|
86
|
+
- Make sure your output folder exists. If it has other name than the default `build`, you can use the `outDir` `(--out-dir)` option.
|
|
87
|
+
- If you are using Vercel hosting and adapter-vercel, look at [this solution](https://github.com/bartholomej/svelte-sitemap/issues/16#issuecomment-961414454).
|
|
88
|
+
|
|
89
|
+
### Error: Missing html files
|
|
90
|
+
|
|
91
|
+
> × There is no static html file in your 'build/' folder. Are you sure you are using Svelte adapter-static with prerender option?
|
|
92
|
+
|
|
93
|
+
This library is intended for the static adapter and `prerender` option (SSG). So if there are no static files, then my library will not work for you :/
|
|
94
|
+
|
|
95
|
+
## ⭐️ Show your support
|
|
96
|
+
|
|
97
|
+
Give a ⭐️ if this project helped you!
|
|
98
|
+
|
|
99
|
+
Or if you are brave enough consider [making a donation](https://github.com/sponsors/bartholomej) for some 🍺 or 🍵 ;)
|
|
100
|
+
|
|
101
|
+
## 🕵️ Privacy Policy
|
|
102
|
+
|
|
103
|
+
I DO NOT STORE ANY DATA. PERIOD.
|
|
104
|
+
|
|
105
|
+
I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.
|
|
106
|
+
|
|
107
|
+
That's why, with this library, what happens on your device stays on your device till disappear.
|
|
108
|
+
|
|
87
109
|
## 🤝 Contributing
|
|
88
110
|
|
|
89
111
|
I welcome you to customize this according to your needs ;)
|
|
@@ -115,20 +137,6 @@ yarn demo
|
|
|
115
137
|
- Brand new version is inspired by [Richard's article](https://r-bt.com/learning/sveltekit-sitemap/)
|
|
116
138
|
- Thanks to [@auderer](https://github.com/auderer) because [his issue](https://github.com/bartholomej/svelte-sitemap/issues/1) changed the direction of this library
|
|
117
139
|
|
|
118
|
-
## ⭐️ Show your support
|
|
119
|
-
|
|
120
|
-
Give a ⭐️ if this project helped you!
|
|
121
|
-
|
|
122
|
-
Or if you are brave enough consider [making a donation](https://github.com/sponsors/bartholomej) for some 🍺 or 🍵 ;)
|
|
123
|
-
|
|
124
|
-
## 🕵️ Privacy Policy
|
|
125
|
-
|
|
126
|
-
I DO NOT STORE ANY DATA. PERIOD.
|
|
127
|
-
|
|
128
|
-
I physically can't. I have nowhere to store it. I don't even have a server database to store it. So even if Justin Bieber asked nicely to see your data, I wouldn't have anything to show him.
|
|
129
|
-
|
|
130
|
-
That's why, with this library, what happens on your device stays on your device till disappear.
|
|
131
|
-
|
|
132
140
|
## 📝 License
|
|
133
141
|
|
|
134
142
|
Copyright © 2022 [Lukas Bartak](http://bartweb.cz)
|
package/index.js
CHANGED
|
@@ -27,7 +27,9 @@ const args = (0, minimist_1.default)(process.argv.slice(2), {
|
|
|
27
27
|
c: 'change-freq',
|
|
28
28
|
C: 'change-freq',
|
|
29
29
|
i: 'ignore',
|
|
30
|
-
I: 'ignore'
|
|
30
|
+
I: 'ignore',
|
|
31
|
+
t: 'trailing-slashes',
|
|
32
|
+
T: 'trailing-slashes'
|
|
31
33
|
},
|
|
32
34
|
unknown: (err) => {
|
|
33
35
|
console.log('⚠ Those arguments are not supported:', err);
|
package/package.json
CHANGED