svelte-sitemap 2.1.3 → 2.3.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 +26 -21
- package/index.js +2 -2
- package/package.json +2 -2
- package/src/helpers/global.helper.js +16 -3
- package/src/interfaces/global.interface.d.ts +5 -1
- package/src/interfaces/global.interface.js +10 -0
package/README.md
CHANGED
|
@@ -60,20 +60,21 @@ Highly recommended to use as `postbuild` hook in your `package.json`
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
## Options
|
|
64
|
-
|
|
65
|
-
| Option | Description
|
|
66
|
-
| ---------------------- |
|
|
67
|
-
| -d, --domain | Use your domain
|
|
68
|
-
| -o, --out-dir | Set custum build folder
|
|
69
|
-
| -i, --ignore | Ignore files or folders
|
|
70
|
-
| -t, --trailing-slashes | Add trailing slashes
|
|
71
|
-
| -r, --reset-time | Set lastModified time to now
|
|
72
|
-
| -
|
|
73
|
-
| -
|
|
74
|
-
| --
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
## ⚙️ Options
|
|
64
|
+
|
|
65
|
+
| Option | Description | default | example |
|
|
66
|
+
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------- | -------------------------------------- |
|
|
67
|
+
| -d, --domain | Use your domain **[required]** | `https://example.com` | `-d https://mydomain.com` |
|
|
68
|
+
| -o, --out-dir | Set custum build folder | `build` | `-o dist` |
|
|
69
|
+
| -i, --ignore | Ignore files or folders | [] | `-i '**/admin/**' -i 'my-secret-page'` |
|
|
70
|
+
| -t, --trailing-slashes | Add trailing slashes | false | `--trailing-slashes` |
|
|
71
|
+
| -r, --reset-time | Set lastModified time to now | false | `-r` |
|
|
72
|
+
| -c, --change-freq | Set change frequency [Option](https://github.com/bartholomej/svelte-sitemap/blob/master/src/interfaces/global.interface.ts#L22) | - | `--change-freq daily` |
|
|
73
|
+
| -h, --help | Display this usage info | - | `-v` |
|
|
74
|
+
| -v, --version | Show version | - | `-h` |
|
|
75
|
+
| --debug | Show some useful logs | - | `--debug` |
|
|
76
|
+
|
|
77
|
+
## 🙋 FAQ
|
|
77
78
|
|
|
78
79
|
#### How to exclude directory?
|
|
79
80
|
|
|
@@ -83,12 +84,14 @@ Highly recommended to use as `postbuild` hook in your `package.json`
|
|
|
83
84
|
npx svelte-sitemap --domain https://www.example.com --ignore 'pages/my-secret-page' --ignore '**/admin/**'
|
|
84
85
|
```
|
|
85
86
|
|
|
86
|
-
##
|
|
87
|
+
## 🤝 Contributing
|
|
87
88
|
|
|
88
89
|
I welcome you to customize this according to your needs ;)
|
|
89
90
|
|
|
90
91
|
Pull requests for any improvements would be great!
|
|
91
92
|
|
|
93
|
+
Feel free to check [issues page](https://github.com/bartholomej/svelte-sitemap/issues).
|
|
94
|
+
|
|
92
95
|
### Developing and debugging this library
|
|
93
96
|
|
|
94
97
|
```bash
|
|
@@ -106,17 +109,19 @@ You can find and modify it in [`./demo.ts`](./demo.ts) file
|
|
|
106
109
|
yarn demo
|
|
107
110
|
```
|
|
108
111
|
|
|
109
|
-
## Credits
|
|
112
|
+
## 🙏 Credits
|
|
110
113
|
|
|
111
114
|
- svelte-sitemap is workaround for [this official SvelteKit issue](https://github.com/sveltejs/kit/issues/1142)
|
|
112
115
|
- Brand new version is inspired by [Richard's article](https://r-bt.com/learning/sveltekit-sitemap/)
|
|
113
116
|
- Thanks to [@auderer](https://github.com/auderer) because [his issue](https://github.com/bartholomej/svelte-sitemap/issues/1) changed the direction of this library
|
|
114
117
|
|
|
115
|
-
##
|
|
118
|
+
## ⭐️ Show your support
|
|
119
|
+
|
|
120
|
+
Give a ⭐️ if this project helped you!
|
|
116
121
|
|
|
117
|
-
|
|
122
|
+
Or if you are brave enough consider [making a donation](https://github.com/sponsors/bartholomej) for some 🍺 or 🍵 ;)
|
|
118
123
|
|
|
119
|
-
## Privacy Policy
|
|
124
|
+
## 🕵️ Privacy Policy
|
|
120
125
|
|
|
121
126
|
I DO NOT STORE ANY DATA. PERIOD.
|
|
122
127
|
|
|
@@ -124,9 +129,9 @@ I physically can't. I have nowhere to store it. I don't even have a server datab
|
|
|
124
129
|
|
|
125
130
|
That's why, with this library, what happens on your device stays on your device till disappear.
|
|
126
131
|
|
|
127
|
-
## License
|
|
132
|
+
## 📝 License
|
|
128
133
|
|
|
129
|
-
Copyright ©
|
|
134
|
+
Copyright © 2022 [Lukas Bartak](http://bartweb.cz)
|
|
130
135
|
|
|
131
136
|
Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)
|
|
132
137
|
|
package/index.js
CHANGED
|
@@ -38,7 +38,7 @@ const args = (0, minimist_1.default)(process.argv.slice(2), {
|
|
|
38
38
|
});
|
|
39
39
|
if (args.help || args.version === '' || args.version === true) {
|
|
40
40
|
const log = args.help ? console.log : console.error;
|
|
41
|
-
log('
|
|
41
|
+
log('Svelte `sitemap.xml` generator');
|
|
42
42
|
log('');
|
|
43
43
|
log(`svelte-sitemap ${package_json_1.version} (check updates: ${REPO_URL})`);
|
|
44
44
|
log('');
|
|
@@ -49,7 +49,7 @@ if (args.help || args.version === '' || args.version === true) {
|
|
|
49
49
|
log(' -i, --ignore Exclude some pages or folders');
|
|
50
50
|
log(' -t, --trailing-slashes Do you like trailing slashes?');
|
|
51
51
|
log(' -r, --reset-time Set modified time to now');
|
|
52
|
-
log(' -c, --change-freq Set change frequency `weekly` | `daily` |
|
|
52
|
+
log(' -c, --change-freq Set change frequency `weekly` | `daily` | …');
|
|
53
53
|
log(' -v, --version Show version');
|
|
54
54
|
log(' --debug Debug mode');
|
|
55
55
|
log(' ');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-sitemap",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Small helper which scans your Svelte routes folder and generates static sitemap.xml",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥 \""
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"fast-glob": "^3.2.
|
|
31
|
+
"fast-glob": "^3.2.11",
|
|
32
32
|
"minimist": "^1.2.5",
|
|
33
33
|
"xmlbuilder2": "^3.0.2"
|
|
34
34
|
},
|
|
@@ -8,6 +8,7 @@ const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const xmlbuilder2_1 = require("xmlbuilder2");
|
|
10
10
|
const package_json_1 = require("../../package.json");
|
|
11
|
+
const global_interface_1 = require("../interfaces/global.interface");
|
|
11
12
|
const vars_1 = require("../vars");
|
|
12
13
|
const vars_helper_1 = require("./vars.helper");
|
|
13
14
|
const getUrl = (url, domain, options) => {
|
|
@@ -28,12 +29,12 @@ async function prepareData(domain, options) {
|
|
|
28
29
|
var _a;
|
|
29
30
|
console.log(vars_helper_1.cliColors.cyanAndBold, `> Using ${vars_1.APP_NAME}`);
|
|
30
31
|
const ignore = prepareIgnored(options === null || options === void 0 ? void 0 : options.ignore, options === null || options === void 0 ? void 0 : options.outDir);
|
|
32
|
+
const changeFreq = prepareChangeFreq(options);
|
|
31
33
|
const pages = await (0, fast_glob_1.default)(`${(_a = options === null || options === void 0 ? void 0 : options.outDir) !== null && _a !== void 0 ? _a : vars_1.OUT_DIR}/**/*.html`, { ignore });
|
|
32
34
|
const results = pages.map((page) => {
|
|
33
|
-
var _a;
|
|
34
35
|
return {
|
|
35
36
|
page: getUrl(page, domain, options),
|
|
36
|
-
changeFreq:
|
|
37
|
+
changeFreq: changeFreq,
|
|
37
38
|
lastMod: (options === null || options === void 0 ? void 0 : options.resetTime) ? new Date().toISOString().split('T')[0] : ''
|
|
38
39
|
};
|
|
39
40
|
});
|
|
@@ -42,7 +43,7 @@ async function prepareData(domain, options) {
|
|
|
42
43
|
exports.prepareData = prepareData;
|
|
43
44
|
const writeSitemap = (items, options) => {
|
|
44
45
|
var _a;
|
|
45
|
-
const sitemap = (0, xmlbuilder2_1.create)({ version: '1.0' }).ele('urlset', {
|
|
46
|
+
const sitemap = (0, xmlbuilder2_1.create)({ version: '1.0', encoding: 'UTF-8' }).ele('urlset', {
|
|
46
47
|
xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'
|
|
47
48
|
});
|
|
48
49
|
if (options === null || options === void 0 ? void 0 : options.attribution) {
|
|
@@ -77,3 +78,15 @@ const prepareIgnored = (ignored, outDir = vars_1.OUT_DIR) => {
|
|
|
77
78
|
}
|
|
78
79
|
return ignore;
|
|
79
80
|
};
|
|
81
|
+
const prepareChangeFreq = (options) => {
|
|
82
|
+
let result = null;
|
|
83
|
+
if (options === null || options === void 0 ? void 0 : options.changeFreq) {
|
|
84
|
+
if (global_interface_1.changeFreq.includes(options.changeFreq)) {
|
|
85
|
+
result = options.changeFreq;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.log(vars_helper_1.cliColors.red, ` × Option \`--change-freq ${options.changeFreq}\` is not a valid value. See docs: https://github.com/bartholomej/svelte-sitemap#options`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
@@ -16,4 +16,8 @@ export interface PagesJson {
|
|
|
16
16
|
changeFreq?: ChangeFreq;
|
|
17
17
|
lastMod?: string;
|
|
18
18
|
}
|
|
19
|
-
export declare
|
|
19
|
+
export declare const changeFreq: readonly ["always", "hourly", "daily", "weekly", "monthly", "yearly", "never"];
|
|
20
|
+
/**
|
|
21
|
+
* Specs: https://www.sitemaps.org/protocol.html
|
|
22
|
+
*/
|
|
23
|
+
export declare type ChangeFreq = typeof changeFreq[number];
|