svelte-sitemap 3.0.0 β†’ 3.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 BART!
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ [![npm version](https://badge.fury.io/js/svelte-sitemap.svg)](https://badge.fury.io/js/svelte-sitemap)
2
+ [![Package License](https://img.shields.io/npm/l/svelte-sitemap.svg)](https://www.npmjs.com/svelte-sitemap)
3
+ [![Build & Publish](https://github.com/bartholomej/svelte-sitemap/workflows/Build%20&%20Publish/badge.svg)](https://github.com/bartholomej/svelte-sitemap/actions)
4
+
5
+ # πŸ—ΊοΈ Svelte `sitemap.xml` generator
6
+
7
+ **Generates `sitemap.xml` from your SvelteKit static routes β€” automatically, on every build.**
8
+
9
+ ---
10
+
11
+ - ➑️ Designed for SvelteKit `adapter-static` with `prerender` option (SSG)
12
+ - πŸ”· TypeScript, JavaScript, CLI version
13
+ - πŸ”§ Useful [options](#%EF%B8%8F-options) for customizing your sitemap
14
+ - πŸ“‘ [Ping](#-ping-google-search-console) Google Search Console after deploy
15
+ - πŸ—‚οΈ Support for [sitemap index](https://developers.google.com/search/docs/crawling-indexing/sitemaps/large-sitemaps) for large sites (50K+ pages)
16
+ - β–² 🟠 Works with [Vercel](#-vercel-adapter) and [Cloudflare](#-cloudflare-adapter) adapters and more...
17
+
18
+ ## πŸ“¦ Install
19
+
20
+ ```bash
21
+ npm install svelte-sitemap --save-dev
22
+ # yarn add svelte-sitemap --dev
23
+ # pnpm add -D svelte-sitemap
24
+ # bun add -d svelte-sitemap
25
+ ```
26
+
27
+ ## πŸš€ Usage
28
+
29
+ > There are three ways to use this library. Pick the one that suits you best.
30
+
31
+ ### ✨ Method 1: Config file (recommended)
32
+
33
+ Create a config file `svelte-sitemap.config.ts` in the root of your project:
34
+
35
+ ```typescript
36
+ // svelte-sitemap.config.ts
37
+ import type { OptionsSvelteSitemap } from 'svelte-sitemap';
38
+
39
+ const config: OptionsSvelteSitemap = {
40
+ domain: 'https://www.example.com',
41
+ trailingSlashes: true
42
+ // ...more options below
43
+ };
44
+
45
+ export default config;
46
+ ```
47
+
48
+ Then add `svelte-sitemap` as a `postbuild` script in `package.json`:
49
+
50
+ ```json
51
+ {
52
+ "scripts": {
53
+ "postbuild": "npx svelte-sitemap"
54
+ }
55
+ }
56
+ ```
57
+
58
+ That's it. After every `build`, the sitemap is automatically generated in your `build/` folder.
59
+
60
+ ---
61
+
62
+ ### ⌨️ Method 2: CLI (legacy)
63
+
64
+ Pass options directly as CLI flags β€” no config file needed:
65
+
66
+ ```json
67
+ {
68
+ "scripts": {
69
+ "postbuild": "npx svelte-sitemap --domain https://myawesomedomain.com"
70
+ }
71
+ }
72
+ ```
73
+
74
+ See all available flags in the [Options](#%EF%B8%8F-options) table below.
75
+
76
+ ---
77
+
78
+ ### πŸ”§ Method 3: JavaScript / TypeScript API
79
+
80
+ Sometimes it's useful to call the script directly from code:
81
+
82
+ ```typescript
83
+ // my-script.js
84
+ import { createSitemap } from 'svelte-sitemap';
85
+
86
+ createSitemap({ domain: 'https://example.com', debug: true });
87
+ ```
88
+
89
+ Run your script:
90
+
91
+ ```bash
92
+ node my-script.js
93
+ ```
94
+
95
+ ---
96
+
97
+ ## βš™οΈ Options
98
+
99
+ Options are defined as **config file keys** (camelCase). Use it in your `svelte-sitemap.config.ts` file.
100
+ _The same options are also available as **CLI flags** for legacy use._
101
+
102
+ | Config key | CLI flag | Description | Default | Example |
103
+ | ----------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------- |
104
+ | `domain` | `--domain`, `-d` | Your domain **[required]** | - | `domain: 'https://mydomain.com'` |
105
+ | `outDir` | `--out-dir`, `-o` | Custom build folder | `build` | `outDir: 'dist'` |
106
+ | `additional` | `--additional`, `-a` | Additional pages outside of SvelteKit | - | `additional: ['my-page', 'my-second-page']` |
107
+ | `ignore` | `--ignore`, `-i` | Ignore files or folders (glob patterns) | `[]` | `ignore: ['**/admin/**', 'my-secret-page']` |
108
+ | `trailingSlashes` | `--trailing-slashes`, `-t` | Add trailing slashes | `false` | `trailingSlashes: true` |
109
+ | `resetTime` | `--reset-time`, `-r` | Set lastModified time to now | `false` | `resetTime: true` |
110
+ | `changeFreq` | `--change-freq`, `-c` | Set change frequency [options](https://github.com/bartholomej/svelte-sitemap/blob/master/src/dto/global.dto.ts#L23) | - | `changeFreq: 'daily'` |
111
+ | `debug` | `--debug` | Show some useful logs | - | `debug: true` |
112
+ | - | `--help`, `-h` | Display usage info | - | - |
113
+ | - | `--version`, `-v` | Show version | - | - |
114
+
115
+ ## πŸ™‹ FAQ
116
+
117
+ ### πŸ™ˆ How to exclude a directory?
118
+
119
+ Use `ignore` with glob patterns. For example, to ignore all `admin` folders and one specific page:
120
+
121
+ ```typescript
122
+ // svelte-sitemap.config.ts
123
+ import type { OptionsSvelteSitemap } from 'svelte-sitemap';
124
+
125
+ const config: OptionsSvelteSitemap = {
126
+ domain: 'https://www.example.com',
127
+ ignore: ['pages/my-secret-page', '**/admin/**']
128
+ };
129
+ ```
130
+
131
+ ---
132
+
133
+ ### πŸ“‘ Ping Google Search Console
134
+
135
+ Every time you deploy a new version, you can inform Google that there's a new update.
136
+ See this [discussion](https://github.com/bartholomej/svelte-sitemap/issues/23) with very useful tips.
137
+
138
+ ---
139
+
140
+ ### β–² Vercel adapter
141
+
142
+ If you're using `adapter-vercel`, the output directory is different from the default `build/`:
143
+
144
+ ```typescript
145
+ // svelte-sitemap.config.ts
146
+ import type { OptionsSvelteSitemap } from 'svelte-sitemap';
147
+
148
+ const config: OptionsSvelteSitemap = {
149
+ domain: 'https://www.example.com',
150
+ outDir: '.vercel/output/static'
151
+ };
152
+ ```
153
+
154
+ Or check out [other solutions](https://github.com/bartholomej/svelte-sitemap/issues/16#issuecomment-961414454) and join the discussion.
155
+
156
+ ---
157
+
158
+ ### 🟠 Cloudflare adapter
159
+
160
+ If you're using `@sveltejs/adapter-cloudflare`, you need to exclude `sitemap.xml` from Cloudflare's routing in `svelte.config.js`:
161
+
162
+ ```diff
163
+ -import adapter from '@sveltejs/adapter-auto';
164
+ +import adapter from '@sveltejs/adapter-cloudflare';
165
+
166
+ /** @type {import('@sveltejs/kit').Config} */
167
+ const config = {
168
+ kit: {
169
+ - adapter: adapter()
170
+ + adapter: adapter({ routes: { include: ['/*'], exclude: ['<all>', '/sitemap.xml'] }})
171
+ }
172
+ };
173
+
174
+ export default config;
175
+ ```
176
+
177
+ ---
178
+
179
+ ## 🐞 Common issues
180
+
181
+ ### ❌ Error: Missing folder
182
+
183
+ ```
184
+ Γ— Folder 'build/' doesn't exist. Make sure you are using this library as 'postbuild'
185
+ so 'build/' folder was successfully created before running this script.
186
+ ```
187
+
188
+ Make sure the output folder exists. If your build outputs to a different folder than `build/`, use the `outDir` option in your config file.
189
+
190
+ ---
191
+
192
+ ### ❌ Error: Missing html files
193
+
194
+ ```
195
+ Γ— There is no static html file in your 'build/' folder.
196
+ Are you sure you are using Svelte adapter-static with prerender option?
197
+ ```
198
+
199
+ This library is intended for `adapter-static` with the `prerender` option (SSG). If there are no static HTML files in your build folder, this library won't work for you :'(
200
+
201
+ ---
202
+
203
+ ## ⭐️ Show your support
204
+
205
+ Give a ⭐️ if this project helped you!
206
+
207
+ Or if you are brave enough consider [making a donation](https://github.com/sponsors/bartholomej) for some 🍺 or 🍡 ;)
208
+
209
+ ## πŸ•΅οΈ Privacy Policy
210
+
211
+ I DO NOT STORE ANY DATA. PERIOD.
212
+
213
+ 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.
214
+
215
+ That's why, with this library, what happens on your device stays on your device till disappear.
216
+
217
+ ## 🀝 Contributing
218
+
219
+ I welcome you to customize this according to your needs ;)
220
+
221
+ Pull requests for any improvements would be great!
222
+
223
+ Feel free to check [issues page](https://github.com/bartholomej/svelte-sitemap/issues).
224
+
225
+ ### πŸ› οΈ Developing and debugging this library
226
+
227
+ ```bash
228
+ git clone git@github.com:bartholomej/svelte-sitemap.git
229
+ cd svelte-sitemap
230
+ yarn
231
+ yarn start
232
+ ```
233
+
234
+ #### Run demo locally
235
+
236
+ You can find and modify it in [`./demo.ts`](./demo.ts) file
237
+
238
+ ```bash
239
+ yarn demo
240
+ ```
241
+
242
+ ## πŸ™ Credits
243
+
244
+ - svelte-sitemap is a workaround for [this official SvelteKit issue](https://github.com/sveltejs/kit/issues/1142)
245
+ - Brand new version is inspired by [Richard's article](https://r-bt.com/learning/sveltekit-sitemap/)
246
+ - Thanks to [@auderer](https://github.com/auderer) because [his issue](https://github.com/bartholomej/svelte-sitemap/issues/1) changed the direction of this library
247
+
248
+ ## πŸ“ License
249
+
250
+ Copyright &copy; 2026 [Lukas Bartak](http://bartweb.cz)
251
+
252
+ Proudly powered by nature πŸ—», wind πŸ’¨, tea 🍡 and beer 🍺 ;)
253
+
254
+ All contents are licensed under the [MIT license].
255
+
256
+ [mit license]: LICENSE
package/cli.js CHANGED
@@ -5,7 +5,6 @@ import { cliColors, errorMsgGeneration } from "./helpers/vars.helper.js";
5
5
  import { createSitemap } from "./index.js";
6
6
  import { defaultConfig, loadConfig, withDefaultConfig } from "./helpers/config.js";
7
7
  import minimist from "minimist";
8
-
9
8
  //#region src/cli.ts
10
9
  const version = version$1;
11
10
  const main = async () => {
@@ -146,7 +145,7 @@ const main = async () => {
146
145
  }
147
146
  };
148
147
  main();
149
-
150
148
  //#endregion
151
- export { };
149
+ export {};
150
+
152
151
  //# sourceMappingURL=cli.js.map
package/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":["pkg.version"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport minimist from 'minimist';\nimport pkg from './../package.json' with { type: 'json' };\nimport { APP_NAME, CONFIG_FILES, REPO_URL } from './const.js';\nimport type { ChangeFreq, OptionsSvelteSitemap } from './dto/index.js';\nimport { defaultConfig, loadConfig, withDefaultConfig } from './helpers/config.js';\nimport { cliColors, errorMsgGeneration } from './helpers/vars.helper.js';\nimport { createSitemap } from './index.js';\nconst version = pkg.version;\n\nconst main = async () => {\n console.log(cliColors.cyanAndBold, `> Using ${APP_NAME}`);\n\n let stop = false;\n\n const config = await loadConfig(CONFIG_FILES);\n\n const args = minimist(process.argv.slice(2), {\n string: ['domain', 'out-dir', 'ignore', 'change-freq', 'additional'],\n boolean: ['attribution', 'reset-time', 'trailing-slashes', 'debug', 'version'],\n default: { attribution: true, 'trailing-slashes': false, default: false },\n alias: {\n d: 'domain',\n D: 'domain',\n h: 'help',\n H: 'help',\n v: 'version',\n V: 'version',\n O: 'out-dir',\n o: 'out-dir',\n r: 'reset-time',\n R: 'reset-time',\n c: 'change-freq',\n C: 'change-freq',\n i: 'ignore',\n I: 'ignore',\n t: 'trailing-slashes',\n T: 'trailing-slashes',\n a: 'additional',\n A: 'additional'\n },\n unknown: (err: string) => {\n if (config && Object.keys(config).length > 0) return false;\n console.log(cliColors.yellow, ' ⚠ This argument is not supported:', err);\n // console.log(cliColors.yellow, ' Use: `svelte-sitemap --help` for more options.');\n stop = true;\n return false;\n }\n });\n\n if (args.help || args.version === '' || args.version === true) {\n const log = args.help ? console.log : console.error;\n log('Svelte `sitemap.xml` generator');\n log('');\n log(`svelte-sitemap ${version} (check updates: ${REPO_URL})`);\n log('');\n log('Options:');\n log('');\n log(' -d, --domain Use your domain (eg. https://example.com)');\n log(' -o, --out-dir Custom output dir');\n log(' -i, --ignore Exclude some pages or folders');\n log(' -a, --additional Additional pages outside of SvelteKit (e.g. /, /contact)');\n log(' -t, --trailing-slashes Do you like trailing slashes?');\n log(' -r, --reset-time Set modified time to now');\n log(' -c, --change-freq Set change frequency `weekly` | `daily` | …');\n log(' -v, --version Show version');\n log(' --debug Debug mode');\n log(' ');\n process.exit(args.help ? 0 : 1);\n } else if (config && Object.keys(config).length > 0) {\n // --- CONFIG FILE PATH ---\n const hasCliOptions = process.argv.slice(2).length > 0;\n console.log(cliColors.green, ` βœ” Reading config file...`);\n\n const allowedKeys = Object.keys(defaultConfig);\n const invalidKeys = Object.keys(config).filter((key) => !allowedKeys.includes(key));\n if (invalidKeys.length > 0) {\n console.log(\n cliColors.yellow,\n ` ⚠ Invalid properties in config file, so I ignore them: ${invalidKeys.join(', ')}`\n );\n }\n\n if (hasCliOptions) {\n console.log(\n cliColors.yellow,\n ` ⚠ You have also set CLI options (arguments with '--'), but they are ignored because your config file 'svelte-sitemap.config.ts' is used.`\n );\n }\n\n if (!config.domain) {\n console.log(\n cliColors.yellow,\n ` ⚠ svelte-sitemap: 'domain' property is required in your config file. See instructions: ${REPO_URL}\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!config.domain.startsWith('https://')) {\n console.log(\n cliColors.yellow,\n ` ⚠ svelte-sitemap: 'domain' property in your config file must start with https:// See instructions: ${REPO_URL}\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n try {\n await createSitemap(withDefaultConfig(config));\n } catch (err) {\n console.error(cliColors.red, errorMsgGeneration, err);\n process.exit(0);\n }\n } else {\n // --- CLI ARGUMENTS PATH ---\n if (stop) {\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!args.domain) {\n console.log(\n cliColors.red,\n ` ⚠ svelte-sitemap: --domain argument is required. See instructions: ${REPO_URL}\\n Example:\\n svelte-sitemap --domain https://mydomain.com\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!args.domain.startsWith('https://')) {\n console.log(\n cliColors.red,\n ` ⚠ svelte-sitemap: --domain argument must start with https:// See instructions: ${REPO_URL}\\n Example:\\n\\n svelte-sitemap --domain https://mydomain.com\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n const domain: string = args.domain;\n const debug: boolean = args.debug === '' || args.debug === true ? true : false;\n const additional = Array.isArray(args['additional'])\n ? args['additional']\n : args.additional\n ? [args.additional]\n : [];\n const resetTime: boolean =\n args['reset-time'] === '' || args['reset-time'] === true ? true : false;\n const trailingSlashes: boolean =\n args['trailing-slashes'] === '' || args['trailing-slashes'] === true ? true : false;\n const changeFreq: ChangeFreq = args['change-freq'];\n const outDir: string = args['out-dir'];\n const ignore: string = args['ignore'];\n const attribution: boolean =\n args['attribution'] === '' || args['attribution'] === false ? false : true;\n\n const optionsCli: OptionsSvelteSitemap = {\n debug,\n resetTime,\n changeFreq,\n outDir,\n domain,\n attribution,\n ignore,\n trailingSlashes,\n additional\n };\n\n console.log(\n cliColors.yellow,\n ` β„Ή Hint: Configuration file is now the preferred method to set up svelte-sitemap. See ${REPO_URL}?tab=readme-ov-file#-usage`\n );\n console.log(cliColors.cyanAndBold, ` βœ” Using CLI options. Config file not found.`);\n try {\n await createSitemap(optionsCli);\n } cat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WAAQ,IACN,UAAU,KACV,oFAAoF,SAAS,oEAC9F;AACD,WAAQ,MAAM,UAAU,KAAK,mBAAmB;AAChD,WAAQ,KAAK,EAAE;;EAGjB,MAAM,SAAiB,KAAK;EAC5B,MAAM,QAAiB,KAAK,UAAU,MAAM,KAAK,UAAU,OAAO,OAAO;EACzE,MAAM,aAAa,MAAM,QAAQ,KAAK,cAAc,GAChD,KAAK,gBACL,KAAK,aACH,CAAC,KAAK,WAAW,GACjB,EAAE;EACR,MAAM,YACJ,KAAK,kBAAkB,MAAM,KAAK,kBAAkB,OAAO,OAAO;EACpE,MAAM,kBACJ,KAAK,wBAAwB,MAAM,KAAK,wBAAwB,OAAO,OAAO;EAChF,MAAM,aAAyB,KAAK;EACpC,MAAM,SAAiB,KAAK;EAC5B,MAAM,SAAiB,KAAK;EAI5B,MAAM,aAAmC;GACvC;GACA;GACA;GACA;GACA;GACA,aARA,KAAK,mBAAmB,MAAM,KAAK,mBAAmB,QAAQ,QAAQ;GAStE;GACA;GACA;GACD;AAED,UAAQ,IACN,UAAU,QACV,0FAA0F,SAAS,4BACpG;AACD,UAAQ,IAAI,UAAU,aAAa,gDAAgD;AACnF,MAAI;AACF,SAAM,cAAc,WAAW;WACxB,KAAK;AACZ,WAAQ,MAAM,UAAU,KAAK,oBAAoB,IAAI;AACrD,WAAQ,KAAK,EAAE;;;;AAKrB,MAAM"}
1
+ {"version":3,"file":"cli.js","names":["pkg.version"],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport minimist from 'minimist';\nimport pkg from './../package.json' with { type: 'json' };\nimport { APP_NAME, CONFIG_FILES, REPO_URL } from './const.js';\nimport type { ChangeFreq, OptionsSvelteSitemap } from './dto/index.js';\nimport { defaultConfig, loadConfig, withDefaultConfig } from './helpers/config.js';\nimport { cliColors, errorMsgGeneration } from './helpers/vars.helper.js';\nimport { createSitemap } from './index.js';\nconst version = pkg.version;\n\nconst main = async () => {\n console.log(cliColors.cyanAndBold, `> Using ${APP_NAME}`);\n\n let stop = false;\n\n const config = await loadConfig(CONFIG_FILES);\n\n const args = minimist(process.argv.slice(2), {\n string: ['domain', 'out-dir', 'ignore', 'change-freq', 'additional'],\n boolean: ['attribution', 'reset-time', 'trailing-slashes', 'debug', 'version'],\n default: { attribution: true, 'trailing-slashes': false, default: false },\n alias: {\n d: 'domain',\n D: 'domain',\n h: 'help',\n H: 'help',\n v: 'version',\n V: 'version',\n O: 'out-dir',\n o: 'out-dir',\n r: 'reset-time',\n R: 'reset-time',\n c: 'change-freq',\n C: 'change-freq',\n i: 'ignore',\n I: 'ignore',\n t: 'trailing-slashes',\n T: 'trailing-slashes',\n a: 'additional',\n A: 'additional'\n },\n unknown: (err: string) => {\n if (config && Object.keys(config).length > 0) return false;\n console.log(cliColors.yellow, ' ⚠ This argument is not supported:', err);\n // console.log(cliColors.yellow, ' Use: `svelte-sitemap --help` for more options.');\n stop = true;\n return false;\n }\n });\n\n if (args.help || args.version === '' || args.version === true) {\n const log = args.help ? console.log : console.error;\n log('Svelte `sitemap.xml` generator');\n log('');\n log(`svelte-sitemap ${version} (check updates: ${REPO_URL})`);\n log('');\n log('Options:');\n log('');\n log(' -d, --domain Use your domain (eg. https://example.com)');\n log(' -o, --out-dir Custom output dir');\n log(' -i, --ignore Exclude some pages or folders');\n log(' -a, --additional Additional pages outside of SvelteKit (e.g. /, /contact)');\n log(' -t, --trailing-slashes Do you like trailing slashes?');\n log(' -r, --reset-time Set modified time to now');\n log(' -c, --change-freq Set change frequency `weekly` | `daily` | …');\n log(' -v, --version Show version');\n log(' --debug Debug mode');\n log(' ');\n process.exit(args.help ? 0 : 1);\n } else if (config && Object.keys(config).length > 0) {\n // --- CONFIG FILE PATH ---\n const hasCliOptions = process.argv.slice(2).length > 0;\n console.log(cliColors.green, ` βœ” Reading config file...`);\n\n const allowedKeys = Object.keys(defaultConfig);\n const invalidKeys = Object.keys(config).filter((key) => !allowedKeys.includes(key));\n if (invalidKeys.length > 0) {\n console.log(\n cliColors.yellow,\n ` ⚠ Invalid properties in config file, so I ignore them: ${invalidKeys.join(', ')}`\n );\n }\n\n if (hasCliOptions) {\n console.log(\n cliColors.yellow,\n ` ⚠ You have also set CLI options (arguments with '--'), but they are ignored because your config file 'svelte-sitemap.config.ts' is used.`\n );\n }\n\n if (!config.domain) {\n console.log(\n cliColors.yellow,\n ` ⚠ svelte-sitemap: 'domain' property is required in your config file. See instructions: ${REPO_URL}\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!config.domain.startsWith('https://')) {\n console.log(\n cliColors.yellow,\n ` ⚠ svelte-sitemap: 'domain' property in your config file must start with https:// See instructions: ${REPO_URL}\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n try {\n await createSitemap(withDefaultConfig(config));\n } catch (err) {\n console.error(cliColors.red, errorMsgGeneration, err);\n process.exit(0);\n }\n } else {\n // --- CLI ARGUMENTS PATH ---\n if (stop) {\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!args.domain) {\n console.log(\n cliColors.red,\n ` ⚠ svelte-sitemap: --domain argument is required. See instructions: ${REPO_URL}\\n Example:\\n svelte-sitemap --domain https://mydomain.com\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n if (!args.domain.startsWith('https://')) {\n console.log(\n cliColors.red,\n ` ⚠ svelte-sitemap: --domain argument must start with https:// See instructions: ${REPO_URL}\\n Example:\\n\\n svelte-sitemap --domain https://mydomain.com\\n`\n );\n console.error(cliColors.red, errorMsgGeneration);\n process.exit(0);\n }\n\n const domain: string = args.domain;\n const debug: boolean = args.debug === '' || args.debug === true ? true : false;\n const additional = Array.isArray(args['additional'])\n ? args['additional']\n : args.additional\n ? [args.additional]\n : [];\n const resetTime: boolean =\n args['reset-time'] === '' || args['reset-time'] === true ? true : false;\n const trailingSlashes: boolean =\n args['trailing-slashes'] === '' || args['trailing-slashes'] === true ? true : false;\n const changeFreq: ChangeFreq = args['change-freq'];\n const outDir: string = args['out-dir'];\n const ignore: string = args['ignore'];\n const attribution: boolean =\n args['attribution'] === '' || args['attribution'] === false ? false : true;\n\n const optionsCli: OptionsSvelteSitemap = {\n debug,\n resetTime,\n changeFreq,\n outDir,\n domain,\n attribution,\n ignore,\n trailingSlashes,\n additional\n };\n\n console.log(\n cliColors.yellow,\n ` β„Ή Hint: Configuration file is now the preferred method to set up svelte-sitemap. See ${REPO_URL}?tab=readme-ov-file#-usage`\n );\n console.log(cliColors.cyanAndBold, ` βœ” Using CLI options. Config file not found.`);\n try {\n await createSitemap(optionsCli);\n } catch (err) {\n console.error(cliColors.red, errorMsgGeneration, err);\n process.exit(0);\n }\n }\n};\n\nmain();\n"],"mappings":";;;;;;;;AAQA,MAAM,UAAUA;AAEhB,MAAM,OAAO,YAAY;AACvB,SAAQ,IAAI,UAAU,aAAa,WAAW,WAAW;CAEzD,IAAI,OAAO;CAEX,MAAM,SAAS,MAAM,WAAW,aAAa;CAE7C,MAAM,OAAO,SAAS,QAAQ,KAAK,MAAM,EAAE,EAAE;EAC3C,QAAQ;GAAC;GAAU;GAAW;GAAU;GAAe;GAAa;EACpE,SAAS;GAAC;GAAe;GAAc;GAAoB;GAAS;GAAU;EAC9E,SAAS;GAAE,aAAa;GAAM,oBAAoB;GAAO,SAAS;GAAO;EACzE,OAAO;GACL,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACH,GAAG;GACJ;EACD,UAAU,QAAgB;AACxB,OAAI,UAAU,OAAO,KAAK,OAAO,CAAC,SAAS,EAAG,QAAO;AACrD,WAAQ,IAAI,UAAU,QAAQ,uCAAuC,IAAI;AAEzE,UAAO;AACP,UAAO;;EAEV,CAAC;AAEF,KAAI,KAAK,QAAQ,KAA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,MAAM"}
package/const.js CHANGED
@@ -21,7 +21,7 @@ const CHANGE_FREQ = [
21
21
  "yearly",
22
22
  "never"
23
23
  ];
24
-
25
24
  //#endregion
26
25
  export { APP_NAME, CHANGE_FREQ, CHUNK, CONFIG_FILES, OUT_DIR, REPO_URL };
26
+
27
27
  //# sourceMappingURL=const.js.map
package/helpers/config.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { OUT_DIR } from "../const.js";
2
2
  import { loadFile } from "./file.js";
3
-
4
3
  //#region src/helpers/config.ts
5
4
  const loadConfig = async (paths) => {
6
5
  for (const path of paths) {
@@ -27,7 +26,7 @@ const updateConfig = (currConfig, newConfig) => {
27
26
  const withDefaultConfig = (config) => {
28
27
  return updateConfig(defaultConfig, config);
29
28
  };
30
-
31
29
  //#endregion
32
30
  export { defaultConfig, loadConfig, withDefaultConfig };
31
+
33
32
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["import { OUT_DIR } from '../const.js';\nimport type { OptionsSvelteSitemap } from '../dto/index.js';\nimport { loadFile } from './file.js';\n\nexport const loadConfig = async (paths: string[]): Promise<OptionsSvelteSitemap | undefined> => {\n for (const path of paths) {\n const config = await loadFile<OptionsSvelteSitemap>(path, false);\n if (config) {\n return config;\n }\n }\n return undefined;\n};\n\nexport const defaultConfig: OptionsSvelteSitemap = {\n debug: false,\n changeFreq: null,\n resetTime: false,\n outDir: OUT_DIR,\n attribution: true,\n ignore: null,\n trailingSlashes: false,\n domain: null\n};\n\nexport const updateConfig = (\n currConfig: OptionsSvelteSitemap,\n newConfig: OptionsSvelteSitemap\n): OptionsSvelteSitemap => {\n return { ...currConfig, ...newConfig };\n};\n\nexport const withDefaultConfig = (config: OptionsSvelteSitemap): OptionsSvelteSitemap => {\n return updateConfig(defaultConfig, config);\n};\n"],"mappings":";;;;AAIA,MAAa,aAAa,OAAO,UAA+D;AAC9F,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,MAAM,SAA+B,MAAM,MAAM;AAChE,MAAI,OACF,QAAO;;;AAMb,MAAa,gBAAsC;CACjD,OAAO;CACP,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,iBAAiB;CACjB,QAAQ;CACT;AAED,MAAa,gBACX,YACA,cACyB;AACzB,QAAO;EAAE,GAAG;EAAY,GAAG;EAAW;;AAGxC,MAAa,qBAAqB,WAAuD;AACvF,QAAO,aAAa,eAAe,OAAO"}
1
+ {"version":3,"file":"config.js","names":[],"sources":["../../src/helpers/config.ts"],"sourcesContent":["import { OUT_DIR } from '../const.js';\nimport type { OptionsSvelteSitemap } from '../dto/index.js';\nimport { loadFile } from './file.js';\n\nexport const loadConfig = async (paths: string[]): Promise<OptionsSvelteSitemap | undefined> => {\n for (const path of paths) {\n const config = await loadFile<OptionsSvelteSitemap>(path, false);\n if (config) {\n return config;\n }\n }\n return undefined;\n};\n\nexport const defaultConfig: OptionsSvelteSitemap = {\n debug: false,\n changeFreq: null,\n resetTime: false,\n outDir: OUT_DIR,\n attribution: true,\n ignore: null,\n trailingSlashes: false,\n domain: null\n};\n\nexport const updateConfig = (\n currConfig: OptionsSvelteSitemap,\n newConfig: OptionsSvelteSitemap\n): OptionsSvelteSitemap => {\n return { ...currConfig, ...newConfig };\n};\n\nexport const withDefaultConfig = (config: OptionsSvelteSitemap): OptionsSvelteSitemap => {\n return updateConfig(defaultConfig, config);\n};\n"],"mappings":";;;AAIA,MAAa,aAAa,OAAO,UAA+D;AAC9F,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,SAAS,MAAM,SAA+B,MAAM,MAAM;AAChE,MAAI,OACF,QAAO;;;AAMb,MAAa,gBAAsC;CACjD,OAAO;CACP,YAAY;CACZ,WAAW;CACX,QAAQ;CACR,aAAa;CACb,QAAQ;CACR,iBAAiB;CACjB,QAAQ;CACT;AAED,MAAa,gBACX,YACA,cACyB;AACzB,QAAO;EAAE,GAAG;EAAY,GAAG;EAAW;;AAGxC,MAAa,qBAAqB,WAAuD;AACvF,QAAO,aAAa,eAAe,OAAO"}
package/helpers/file.js CHANGED
@@ -2,7 +2,6 @@ import { existsSync } from "fs";
2
2
  import { createJiti } from "jiti";
3
3
  import { resolve } from "path";
4
4
  import { fileURLToPath } from "url";
5
-
6
5
  //#region src/helpers/file.ts
7
6
  const jiti = createJiti(fileURLToPath(import.meta.url));
8
7
  const loadFile = async (fileName, throwError = true) => {
@@ -15,7 +14,7 @@ const loadFile = async (fileName, throwError = true) => {
15
14
  if (throwError) throw new Error(`${filePath} does not exist.`);
16
15
  return null;
17
16
  };
18
-
19
17
  //#endregion
20
18
  export { loadFile };
19
+
21
20
  //# sourceMappingURL=file.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","names":[],"sources":["../../src/helpers/file.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { createJiti } from 'jiti';\nimport { resolve } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst filename = fileURLToPath(import.meta.url);\nconst jiti = createJiti(filename);\n\nexport const loadFile = async <T>(fileName: string, throwError = true): Promise<T | null> => {\n const filePath = resolve(resolve(process.cwd(), fileName));\n\n if (existsSync(filePath)) {\n try {\n const module = await jiti.import(filePath, { default: true });\n return module as T;\n } catch (err: any) {\n throw err;\n }\n }\n\n if (throwError) {\n throw new Error(`${filePath} does not exist.`);\n }\n return null;\n};\n"],"mappings":";;;;;;AAMA,MAAM,OAAO,WADI,cAAc,OAAO,KAAK,IAAI,CACd;AAEjC,MAAa,WAAW,OAAU,UAAkB,aAAa,SAA4B;CAC3F,MAAM,WAAW,QAAQ,QAAQ,QAAQ,KAAK,EAAE,SAAS,CAAC;AAE1D,KAAI,WAAW,SAAS,CACtB,KAAI;AAEF,SADe,MAAM,KAAK,OAAO,UAAU,EAAE,SAAS,MAAM,CAAC;UAEtD,KAAU;AACjB,QAAM;;AAIV,KAAI,WACF,OAAM,IAAI,MAAM,GAAG,SAAS,kBAAkB;AAEhD,QAAO"}
1
+ {"version":3,"file":"file.js","names":[],"sources":["../../src/helpers/file.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { createJiti } from 'jiti';\nimport { resolve } from 'path';\nimport { fileURLToPath } from 'url';\n\nconst filename = fileURLToPath(import.meta.url);\nconst jiti = createJiti(filename);\n\nexport const loadFile = async <T>(fileName: string, throwError = true): Promise<T | null> => {\n const filePath = resolve(resolve(process.cwd(), fileName));\n\n if (existsSync(filePath)) {\n try {\n const module = await jiti.import(filePath, { default: true });\n return module as T;\n } catch (err: any) {\n throw err;\n }\n }\n\n if (throwError) {\n throw new Error(`${filePath} does not exist.`);\n }\n return null;\n};\n"],"mappings":";;;;;AAMA,MAAM,OAAO,WADI,cAAc,OAAO,KAAK,IAAI,CACd;AAEjC,MAAa,WAAW,OAAU,UAAkB,aAAa,SAA4B;CAC3F,MAAM,WAAW,QAAQ,QAAQ,QAAQ,KAAK,EAAE,SAAS,CAAC;AAE1D,KAAI,WAAW,SAAS,CACtB,KAAI;AAEF,SADe,MAAM,KAAK,OAAO,UAAU,EAAE,SAAS,MAAM,CAAC;UAEtD,KAAU;AACjB,QAAM;;AAIV,KAAI,WACF,OAAM,IAAI,MAAM,GAAG,SAAS,kBAAkB;AAEhD,QAAO"}
@@ -4,12 +4,11 @@ import { cliColors, errorMsgFolder, errorMsgHtmlFiles, errorMsgWrite, successMsg
4
4
  import fg from "fast-glob";
5
5
  import fs from "fs";
6
6
  import { create } from "xmlbuilder2";
7
-
8
7
  //#region src/helpers/global.helper.ts
9
8
  const version = version$1;
10
9
  const getUrl = (url, domain, options) => {
11
10
  let slash = getSlash(domain);
12
- let trimmed = url.split((options?.outDir ?? OUT_DIR) + "/").pop().replace("index.html", "");
11
+ let trimmed = url.split((options?.outDir ?? "build") + "/").pop().replace("index.html", "");
13
12
  trimmed = removeHtml(trimmed);
14
13
  if (options?.trailingSlashes) trimmed = trimmed.length && !trimmed.endsWith("/") ? trimmed + "/" : trimmed;
15
14
  else {
@@ -23,7 +22,7 @@ const removeHtml = (fileName) => {
23
22
  return fileName;
24
23
  };
25
24
  async function prepareData(domain, options) {
26
- const FOLDER = options?.outDir ?? OUT_DIR;
25
+ const FOLDER = options?.outDir ?? "build";
27
26
  const ignore = prepareIgnored(options?.ignore, options?.outDir);
28
27
  const changeFreq = prepareChangeFreq(options);
29
28
  const pages = await fg(`${FOLDER}/**/*.html`, { ignore });
@@ -46,7 +45,7 @@ const detectErrors = ({ folder, htmlFiles }) => {
46
45
  else if (htmlFiles) console.error(cliColors.red, errorMsgHtmlFiles(OUT_DIR));
47
46
  };
48
47
  const writeSitemap = (items, options, domain) => {
49
- const outDir = options?.outDir ?? OUT_DIR;
48
+ const outDir = options?.outDir ?? "build";
50
49
  if (items?.length <= CHUNK.maxSize) createFile(items, options, outDir);
51
50
  else {
52
51
  const numberOfChunks = Math.ceil(items.length / CHUNK.maxSize);
@@ -114,7 +113,7 @@ const finishXml = (sitemap) => {
114
113
  const addAttribution = (sitemap, options) => {
115
114
  if (options?.attribution !== false) sitemap.com(` This file was automatically generated by https://github.com/bartholomej/svelte-sitemap v${version} `);
116
115
  };
117
-
118
116
  //#endregion
119
117
  export { prepareData, writeSitemap };
118
+
120
119
  //# sourceMappingURL=global.helper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.helper.js","names":["pkg.version"],"sources":["../../src/helpers/global.helper.ts"],"sourcesContent":["import fg from 'fast-glob';\nimport fs from 'fs';\nimport { create } from 'xmlbuilder2';\nimport type { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { CHANGE_FREQ, CHUNK, OUT_DIR } from '../const.js';\nimport type { ChangeFreq, Options, OptionsSvelteSitemap, PagesJson } from './../dto/index.js';\nimport {\n cliColors,\n errorMsgFolder,\n errorMsgHtmlFiles,\n errorMsgWrite,\n successMsg\n} from './vars.helper.js';\n\nconst version = pkg.version;\n\nconst getUrl = (url: string, domain: string, options: Options) => {\n let slash: '' | '/' = getSlash(domain);\n\n let trimmed = url\n .split((options?.outDir ?? OUT_DIR) + '/')\n .pop()\n .replace('index.html', '');\n\n trimmed = removeHtml(trimmed);\n\n // Add all traling slashes\n if (options?.trailingSlashes) {\n trimmed = trimmed.length && !trimmed.endsWith('/') ? trimmed + '/' : trimmed;\n } else {\n trimmed = trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;\n slash = trimmed ? slash : '';\n }\n return `${domain}${slash}${trimmed}`;\n};\n\nexport const removeHtml = (fileName: string) => {\n if (fileName?.endsWith('.html')) {\n return fileName.slice(0, -5);\n }\n return fileName;\n};\n\nexport async function prepareData(domain: string, options?: Options): Promise<PagesJson[]> {\n const FOLDER = options?.outDir ?? OUT_DIR;\n\n const ignore = prepareIgnored(options?.ignore, options?.outDir);\n const changeFreq = prepareChangeFreq(options);\n const pages: string[] = await fg(`${FOLDER}/**/*.html`, { ignore });\n\n if (options.additional) pages.push(...options.additional);\n\n const results = pages.map((page) => {\n return {\n page: getUrl(page, domain, options),\n changeFreq: changeFreq,\n lastMod: options?.resetTime ? new Date().toISOString().split('T')[0] : ''\n };\n });\n\n detectErrors({\n folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n });\n\n return results;\n}\n\nexport const detectErrors = ({ folder, htmlFiles }: { folder: boolean; htmlFiles: boolean }) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(OUT_DIR));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(OUT_DIR));\n }\n};\n\nexport const writeSitemap = (items: PagesJson[], options: Options, domain: string): void => {\n const outDir = options?.outDir ?? OUT_DIR;\n\n if (items?.length <= CHUNK.maxSize) {\n createFile(items, options, outDir);\n } else {\n // If the number of pages is greater than the chunk size, then we split the sitemap into multiple files\n // and create an index file that links to all of them\n // https://support.google.com/webmasters/answer/183668?hl=en\n const numberOfChunks = Math.ceil(items.length / CHUNK.maxSize);\n\n console.log(\n cliColors.cyanAndBold,\n `> Oh, your site is huge! Writing sitemap in chunks of ${numberOfChunks} pages and its index sitemap.xml`\n );\n\n for (let i = 0; i < items.length; i += CHUNK.maxSize) {\n const chunk = items.slice(i, i + CHUNK.maxSize);\n createFile(chunk, options, outDir, i / CHUNK.maxSize + 1);\n }\n createIndexFile(numberOfChunks, outDir, options, domain);\n }\n};\n\nconst createFile = (\n items: PagesJson[],\n options: Options,\n outDir: string,\n chunkId?: number\n): void => {\n const sitemap = createXml('urlset');\n addAttribution(sitemap, options);\n\n for (const item of items) {\n const page = sitemap.ele('url');\n page.ele('loc').txt(item.page);\n if (item.changeFreq) {\n page.ele('changefreq').txt(item.changeFreq);\n }\n if (item.lastMod) {\n page.ele('lastmod').txt(item.lastMod);\n }\n }\n\n const xml = finishXml(sitemap);\n\n const fileName = chunkId ? `sitemap-${chunkId}.xml` : 'sitemap.xml';\n\n try {\n fs.writeFileSync(`${outDir}/${fileName}`, xml);\n console.log(cliColors.green, successMsg(outDir, fileName));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, fileName), e);\n }\n};\n\nconst createIndexFile = (\n numberOfChunks: number,\n outDir: string,\n options: Options,\n domain: string\n): void => {\n const FILENAME = 'sitemap.xml';\n const slash = getSlash(domain);\n\n const sitemap = createXml('sitemapindex');\n addAttribution(sitemap, options);\n\n for (let i = 1; i <= numberOfChunks; i++) {\n sitemap.ele('sitemap').ele('loc').txt(`${domain}${slash}sitemap-${i}.xml`);\n }\n\n const xml = finishXml(sitemap);\n\n try {\n fs.writeFileSync(`${outDir}/${FILENAME}`, xml);\n console.log(cliColors.green, successMsg(outDir, FILENAME));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, FILENAME), e);\n }\n};\n\nconst prepareIgnored = (\n ignored: string | string[],\n outDir: string = OUT_DIR\n): string[] | undefined => {\n let ignore: string[] | undefined;\n if (ignored) {\n ignore = Array.isArray(ignored) ? ignored : [ignored];\n ignore = ignore.map((ignoredPage) => `${outDir}/${ignoredPage}`);\n }\n return ignore;\n};\n\nconst prepareChangeFreq = (options: Options): ChangeFreq => {\n let result: ChangeFreq = null;\n\n if (options?.changeFreq) {\n if (CHANGE_FREQ.includes(options.changeFreq)) {\n result = options.changeFreq;\n } else {\n console.log(\n cliColors.red,\n ` Γ— Option \\`--change-freq ${options.changeFreq}\\` is not a valid value. See docs: https://github.com/bartholomej/svelte-sitemap#options`\n );\n }\n }\n return result;\n};\n\nconst getSlash = (domain: string) => (domain.split('/').pop() ? '/' : '');\n\nconst createXml = (elementName: 'urlset' | 'sitemapindex'): XMLBuilder => {\n return create({ version: '1.0', encoding: 'UTF-8' }).ele(elementName, {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'\n });\n};\n\nconst finishXml = (sitemap: XMLBuilder): string => {\n return sitemap.end({ prettyPrint: true });\n};\n\nconst addAttribution = (sitemap: XMLBuilder, options: Options): void => {\n if (options?.attribution !== false) {\n sitemap.com(\n ` This file was automatically generated by https://github.com/bartholomej/svelte-sitemap v${version} `\n );\n }\n};\n"],"mappings":";;;;;;;;AAeA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,OAAO;CAEtC,IAAI,UAAU,IACX,OAAO,SAAS,UAAU,WAAW,IAAI,CACzC,KAAK,CACL,QAAQ,cAAc,GAAG;AAE5B,WAAU,WAAW,QAAQ;AAG7B,KAAI,SAAS,gBACX,WAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,UAAU,MAAM;MAChE;AACL,YAAU,QAAQ,SAAS,IAAI,GAAG,QAAQ,MAAM,GAAG,GAAG,GAAG;AACzD,UAAQ,UAAU,QAAQ;;AAE5B,QAAO,GAAG,SAAS,QAAQ;;AAG7B,MAAa,cAAc,aAAqB;AAC9C,KAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO,SAAS,MAAM,GAAG,GAAG;AAE9B,QAAO;;AAGT,eAAsB,YA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GAAG,cAAc;;AAElE,QAAO;;AAGT,MAAM,qBAAqB,YAAiC;CAC1D,IAAI,SAAqB;AAEzB,KAAI,SAAS,WACX,KAAI,YAAY,SAAS,QAAQ,WAAW,CAC1C,UAAS,QAAQ;KAEjB,SAAQ,IACN,UAAU,KACV,8BAA8B,QAAQ,WAAW,0FAClD;AAGL,QAAO;;AAGT,MAAM,YAAY,WAAoB,OAAO,MAAM,IAAI,CAAC,KAAK,GAAG,MAAM;AAEtE,MAAM,aAAa,gBAAuD;AACxE,QAAO,OAAO;EAAE,SAAS;EAAO,UAAU;EAAS,CAAC,CAAC,IAAI,aAAa,EACpE,OAAO,+CACR,CAAC;;AAGJ,MAAM,aAAa,YAAgC;AACjD,QAAO,QAAQ,IAAI,EAAE,aAAa,MAAM,CAAC;;AAG3C,MAAM,kBAAkB,SAAqB,YAA2B;AACtE,KAAI,SAAS,gBAAgB,MAC3B,SAAQ,IACN,4FAA4F,QAAQ,GACrG"}
1
+ {"version":3,"file":"global.helper.js","names":["pkg.version"],"sources":["../../src/helpers/global.helper.ts"],"sourcesContent":["import fg from 'fast-glob';\nimport fs from 'fs';\nimport { create } from 'xmlbuilder2';\nimport type { XMLBuilder } from 'xmlbuilder2/lib/interfaces.js';\nimport pkg from '../../package.json' with { type: 'json' };\nimport { CHANGE_FREQ, CHUNK, OUT_DIR } from '../const.js';\nimport type { ChangeFreq, Options, OptionsSvelteSitemap, PagesJson } from './../dto/index.js';\nimport {\n cliColors,\n errorMsgFolder,\n errorMsgHtmlFiles,\n errorMsgWrite,\n successMsg\n} from './vars.helper.js';\n\nconst version = pkg.version;\n\nconst getUrl = (url: string, domain: string, options: Options) => {\n let slash: '' | '/' = getSlash(domain);\n\n let trimmed = url\n .split((options?.outDir ?? OUT_DIR) + '/')\n .pop()\n .replace('index.html', '');\n\n trimmed = removeHtml(trimmed);\n\n // Add all traling slashes\n if (options?.trailingSlashes) {\n trimmed = trimmed.length && !trimmed.endsWith('/') ? trimmed + '/' : trimmed;\n } else {\n trimmed = trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;\n slash = trimmed ? slash : '';\n }\n return `${domain}${slash}${trimmed}`;\n};\n\nexport const removeHtml = (fileName: string) => {\n if (fileName?.endsWith('.html')) {\n return fileName.slice(0, -5);\n }\n return fileName;\n};\n\nexport async function prepareData(domain: string, options?: Options): Promise<PagesJson[]> {\n const FOLDER = options?.outDir ?? OUT_DIR;\n\n const ignore = prepareIgnored(options?.ignore, options?.outDir);\n const changeFreq = prepareChangeFreq(options);\n const pages: string[] = await fg(`${FOLDER}/**/*.html`, { ignore });\n\n if (options.additional) pages.push(...options.additional);\n\n const results = pages.map((page) => {\n return {\n page: getUrl(page, domain, options),\n changeFreq: changeFreq,\n lastMod: options?.resetTime ? new Date().toISOString().split('T')[0] : ''\n };\n });\n\n detectErrors({\n folder: !fs.existsSync(FOLDER),\n htmlFiles: !pages.length\n });\n\n return results;\n}\n\nexport const detectErrors = ({ folder, htmlFiles }: { folder: boolean; htmlFiles: boolean }) => {\n if (folder && htmlFiles) {\n console.error(cliColors.red, errorMsgFolder(OUT_DIR));\n } else if (htmlFiles) {\n // If no page exists, then the static adapter is probably not used\n console.error(cliColors.red, errorMsgHtmlFiles(OUT_DIR));\n }\n};\n\nexport const writeSitemap = (items: PagesJson[], options: Options, domain: string): void => {\n const outDir = options?.outDir ?? OUT_DIR;\n\n if (items?.length <= CHUNK.maxSize) {\n createFile(items, options, outDir);\n } else {\n // If the number of pages is greater than the chunk size, then we split the sitemap into multiple files\n // and create an index file that links to all of them\n // https://support.google.com/webmasters/answer/183668?hl=en\n const numberOfChunks = Math.ceil(items.length / CHUNK.maxSize);\n\n console.log(\n cliColors.cyanAndBold,\n `> Oh, your site is huge! Writing sitemap in chunks of ${numberOfChunks} pages and its index sitemap.xml`\n );\n\n for (let i = 0; i < items.length; i += CHUNK.maxSize) {\n const chunk = items.slice(i, i + CHUNK.maxSize);\n createFile(chunk, options, outDir, i / CHUNK.maxSize + 1);\n }\n createIndexFile(numberOfChunks, outDir, options, domain);\n }\n};\n\nconst createFile = (\n items: PagesJson[],\n options: Options,\n outDir: string,\n chunkId?: number\n): void => {\n const sitemap = createXml('urlset');\n addAttribution(sitemap, options);\n\n for (const item of items) {\n const page = sitemap.ele('url');\n page.ele('loc').txt(item.page);\n if (item.changeFreq) {\n page.ele('changefreq').txt(item.changeFreq);\n }\n if (item.lastMod) {\n page.ele('lastmod').txt(item.lastMod);\n }\n }\n\n const xml = finishXml(sitemap);\n\n const fileName = chunkId ? `sitemap-${chunkId}.xml` : 'sitemap.xml';\n\n try {\n fs.writeFileSync(`${outDir}/${fileName}`, xml);\n console.log(cliColors.green, successMsg(outDir, fileName));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, fileName), e);\n }\n};\n\nconst createIndexFile = (\n numberOfChunks: number,\n outDir: string,\n options: Options,\n domain: string\n): void => {\n const FILENAME = 'sitemap.xml';\n const slash = getSlash(domain);\n\n const sitemap = createXml('sitemapindex');\n addAttribution(sitemap, options);\n\n for (let i = 1; i <= numberOfChunks; i++) {\n sitemap.ele('sitemap').ele('loc').txt(`${domain}${slash}sitemap-${i}.xml`);\n }\n\n const xml = finishXml(sitemap);\n\n try {\n fs.writeFileSync(`${outDir}/${FILENAME}`, xml);\n console.log(cliColors.green, successMsg(outDir, FILENAME));\n } catch (e) {\n console.error(cliColors.red, errorMsgWrite(outDir, FILENAME), e);\n }\n};\n\nconst prepareIgnored = (\n ignored: string | string[],\n outDir: string = OUT_DIR\n): string[] | undefined => {\n let ignore: string[] | undefined;\n if (ignored) {\n ignore = Array.isArray(ignored) ? ignored : [ignored];\n ignore = ignore.map((ignoredPage) => `${outDir}/${ignoredPage}`);\n }\n return ignore;\n};\n\nconst prepareChangeFreq = (options: Options): ChangeFreq => {\n let result: ChangeFreq = null;\n\n if (options?.changeFreq) {\n if (CHANGE_FREQ.includes(options.changeFreq)) {\n result = options.changeFreq;\n } else {\n console.log(\n cliColors.red,\n ` Γ— Option \\`--change-freq ${options.changeFreq}\\` is not a valid value. See docs: https://github.com/bartholomej/svelte-sitemap#options`\n );\n }\n }\n return result;\n};\n\nconst getSlash = (domain: string) => (domain.split('/').pop() ? '/' : '');\n\nconst createXml = (elementName: 'urlset' | 'sitemapindex'): XMLBuilder => {\n return create({ version: '1.0', encoding: 'UTF-8' }).ele(elementName, {\n xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'\n });\n};\n\nconst finishXml = (sitemap: XMLBuilder): string => {\n return sitemap.end({ prettyPrint: true });\n};\n\nconst addAttribution = (sitemap: XMLBuilder, options: Options): void => {\n if (options?.attribution !== false) {\n sitemap.com(\n ` This file was automatically generated by https://github.com/bartholomej/svelte-sitemap v${version} `\n );\n }\n};\n"],"mappings":";;;;;;;AAeA,MAAM,UAAUA;AAEhB,MAAM,UAAU,KAAa,QAAgB,YAAqB;CAChE,IAAI,QAAkB,SAAS,OAAO;CAEtC,IAAI,UAAU,IACX,OAAO,SAAS,UAAA,WAAqB,IAAI,CACzC,KAAK,CACL,QAAQ,cAAc,GAAG;AAE5B,WAAU,WAAW,QAAQ;AAG7B,KAAI,SAAS,gBACX,WAAU,QAAQ,UAAU,CAAC,QAAQ,SAAS,IAAI,GAAG,UAAU,MAAM;MAChE;AACL,YAAU,QAAQ,SAAS,IAAI,GAAG,QAAQ,MAAM,GAAG,GAAG,GAAG;AACzD,UAAQ,UAAU,QAAQ;;AAE5B,QAAO,GAAG,SAAS,QAAQ;;AAG7B,MAAa,cAAc,aAAqB;AAC9C,KAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO,SAAS,MAAM,GAAG,GAAG;AAE9B,QAAO;;AAGT,eAAsB,YAAY,QAAgB,SAAyC;CACzF,MAAM,SAAS,SAAS,UAAA;CAExB,MAAM,SAAS,eAAe,SAAS,QAAQ,SAAS,OAAO;CAC/D,MAAM,aAAa,kBAAkB,QAAQ;CAC7C,MAAM,QAAkB,MAAM,GAAG,GAAG,OAAO,aAAa,EAAE,QAAQ,CAAC;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0FAClD;AAGL,QAAO;;AAGT,MAAM,YAAY,WAAoB,OAAO,MAAM,IAAI,CAAC,KAAK,GAAG,MAAM;AAEtE,MAAM,aAAa,gBAAuD;AACxE,QAAO,OAAO;EAAE,SAAS;EAAO,UAAU;EAAS,CAAC,CAAC,IAAI,aAAa,EACpE,OAAO,+CACR,CAAC;;AAGJ,MAAM,aAAa,YAAgC;AACjD,QAAO,QAAQ,IAAI,EAAE,aAAa,MAAM,CAAC;;AAG3C,MAAM,kBAAkB,SAAqB,YAA2B;AACtE,KAAI,SAAS,gBAAgB,MAC3B,SAAQ,IACN,4FAA4F,QAAQ,GACrG"}
@@ -10,7 +10,7 @@ const errorMsgWrite = (outDir, filename) => ` Γ— File '${outDir}/${filename}' c
10
10
  const errorMsgGeneration = ` Γ— Sitemap generation failed.`;
11
11
  const errorMsgFolder = (outDir) => ` Γ— Folder '${outDir}/' doesn't exist.\n Make sure you are using this library as 'postbuild' so '${outDir}/' folder was successfully created before running this script. Or are you using Vercel? See https://github.com/bartholomej/svelte-sitemap#error-missing-folder`;
12
12
  const errorMsgHtmlFiles = (outDir) => ` Γ— There is no static html file in your '${outDir}/' folder. Are you sure you are using Svelte adapter-static with prerender option? See https://github.com/bartholomej/svelte-sitemap#error-missing-html-files`;
13
-
14
13
  //#endregion
15
14
  export { cliColors, errorMsgFolder, errorMsgGeneration, errorMsgHtmlFiles, errorMsgWrite, successMsg };
15
+
16
16
  //# sourceMappingURL=vars.helper.js.map
package/index.js CHANGED
@@ -1,16 +1,15 @@
1
- import { OUT_DIR } from "./const.js";
1
+ import "./const.js";
2
2
  import { cliColors, errorMsgWrite } from "./helpers/vars.helper.js";
3
3
  import { prepareData, writeSitemap } from "./helpers/global.helper.js";
4
-
5
4
  //#region src/index.ts
6
5
  const createSitemap = async (options) => {
7
6
  if (options?.debug) console.log("OPTIONS", options);
8
7
  const json = await prepareData(options.domain, options);
9
8
  if (options?.debug) console.log("RESULT", json);
10
9
  if (json.length) writeSitemap(json, options, options.domain);
11
- else console.error(cliColors.red, errorMsgWrite(options.outDir ?? OUT_DIR, "sitemap.xml"));
10
+ else console.error(cliColors.red, errorMsgWrite(options.outDir ?? "build", "sitemap.xml"));
12
11
  };
13
-
14
12
  //#endregion
15
13
  export { createSitemap };
14
+
16
15
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { OUT_DIR } from './const.js';\nimport type { OptionsSvelteSitemap } from './dto/index.js';\nimport { prepareData, writeSitemap } from './helpers/global.helper.js';\nimport { cliColors, errorMsgWrite } from './helpers/vars.helper.js';\n\nexport const createSitemap = async (options: OptionsSvelteSitemap): Promise<void> => {\n if (options?.debug) {\n console.log('OPTIONS', options);\n }\n\n const json = await prepareData(options.domain, options);\n\n if (options?.debug) {\n console.log('RESULT', json);\n }\n\n if (json.length) {\n writeSitemap(json, options, options.domain);\n } else {\n console.error(cliColors.red, errorMsgWrite(options.outDir ?? OUT_DIR, 'sitemap.xml'));\n }\n};\n\nexport type * from './dto/index.js';\n"],"mappings":";;;;;AAKA,MAAa,gBAAgB,OAAO,YAAiD;AACnF,KAAI,SAAS,MACX,SAAQ,IAAI,WAAW,QAAQ;CAGjC,MAAM,OAAO,MAAM,YAAY,QAAQ,QAAQ,QAAQ;AAEvD,KAAI,SAAS,MACX,SAAQ,IAAI,UAAU,KAAK;AAG7B,KAAI,KAAK,OACP,cAAa,MAAM,SAAS,QAAQ,OAAO;KAE3C,SAAQ,MAAM,UAAU,KAAK,cAAc,QAAQ,UAAU,SAAS,cAAc,CAAC"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { OUT_DIR } from './const.js';\nimport type { OptionsSvelteSitemap } from './dto/index.js';\nimport { prepareData, writeSitemap } from './helpers/global.helper.js';\nimport { cliColors, errorMsgWrite } from './helpers/vars.helper.js';\n\nexport const createSitemap = async (options: OptionsSvelteSitemap): Promise<void> => {\n if (options?.debug) {\n console.log('OPTIONS', options);\n }\n\n const json = await prepareData(options.domain, options);\n\n if (options?.debug) {\n console.log('RESULT', json);\n }\n\n if (json.length) {\n writeSitemap(json, options, options.domain);\n } else {\n console.error(cliColors.red, errorMsgWrite(options.outDir ?? OUT_DIR, 'sitemap.xml'));\n }\n};\n\nexport type * from './dto/index.js';\n"],"mappings":";;;;AAKA,MAAa,gBAAgB,OAAO,YAAiD;AACnF,KAAI,SAAS,MACX,SAAQ,IAAI,WAAW,QAAQ;CAGjC,MAAM,OAAO,MAAM,YAAY,QAAQ,QAAQ,QAAQ;AAEvD,KAAI,SAAS,MACX,SAAQ,IAAI,UAAU,KAAK;AAG7B,KAAI,KAAK,OACP,cAAa,MAAM,SAAS,QAAQ,OAAO;KAE3C,SAAQ,MAAM,UAAU,KAAK,cAAc,QAAQ,UAAA,SAAmB,cAAc,CAAC"}
package/package.js CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region package.json
2
- var version = "3.0.0";
3
-
2
+ var version = "3.0.1";
4
3
  //#endregion
5
4
  export { version };
5
+
6
6
  //# sourceMappingURL=package.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-sitemap",
3
- "version": "3.0.0",
3
+ "version": "3.0.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>",
@@ -35,6 +35,28 @@
35
35
  "engines": {
36
36
  "node": ">= 14.17.0"
37
37
  },
38
+ "funding": [
39
+ {
40
+ "type": "github",
41
+ "url": "https://github.com/sponsors/bartholomej"
42
+ },
43
+ {
44
+ "type": "ko_fi",
45
+ "url": "https://ko-fi.com/bartholomej"
46
+ },
47
+ {
48
+ "type": "buy_me_a_coffee",
49
+ "url": "https://www.buymeacoffee.com/bartholomej"
50
+ },
51
+ {
52
+ "type": "paypal",
53
+ "url": "https://www.paypal.me/bartholomej"
54
+ },
55
+ {
56
+ "type": "thanks_dev",
57
+ "url": "https://thanks.dev/u/gh/bartholomej"
58
+ }
59
+ ],
38
60
  "license": "MIT",
39
61
  "types": "./index.d.ts",
40
62
  "exports": {