Skip to content

Commit 7143423

Browse files
committed
docs(readme): add config file instructions
1 parent 201593a commit 7143423

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

README.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@ yarn add svelte-sitemap --dev
2222

2323
## Usage
2424

25-
### CLI method (recommended)
25+
### Config file method (recommended)
26+
27+
Create config file `svelte-sitemap.cjs` in the root of your project:
28+
29+
`svelte-sitemap.cjs`
30+
31+
```js
32+
module.exports = {
33+
domain: 'https://www.example.com'
34+
// ...more options
35+
};
36+
```
37+
38+
Add `svelte-sitemap` as your postbuild script in `package.json` file:
39+
40+
`package.json`
41+
42+
```json
43+
{
44+
"postbuild": "npx svelte-sitemap"
45+
}
46+
```
47+
48+
### CLI method (Alternative 1)
2649

2750
Run in your project root folder to see how it works.
2851

@@ -35,7 +58,7 @@ yarn svelte-sitemap --domain https://example.com
3558

3659
It scans your routes in `build/` folder and generates `build/sitemap.xml` file
3760

38-
### TypeScript or JavaScript method (optional)
61+
### TypeScript or JavaScript method (Alternative 2)
3962

4063
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.
4164

@@ -49,13 +72,13 @@ And now you can run your script like this: `node my-script.js`
4972

5073
## Example
5174

52-
Highly recommended to use as `postbuild` hook in your `package.json`
75+
Highly recommended to use as `postbuild` hook in your `package.json` with config file `svelte-sitemap.cjs` in your project root.
5376

5477
```json
5578
{
5679
"name": "my-project",
5780
"scripts": {
58-
"postbuild": "npx svelte-sitemap --domain https://mydomain.com"
81+
"postbuild": "npx svelte-sitemap"
5982
}
6083
}
6184
```
@@ -114,6 +137,7 @@ yarn demo
114137
- svelte-sitemap is workaround for [this official SvelteKit issue](https://github.com/sveltejs/kit/issues/1142)
115138
- Brand new version is inspired by [Richard's article](https://r-bt.com/learning/sveltekit-sitemap/)
116139
- Thanks to [@auderer](https://github.com/auderer) because [his issue](https://github.com/bartholomej/svelte-sitemap/issues/1) changed the direction of this library
140+
- Config files inspired by [next-sitemap](https://github.com/iamvishnusankar/next-sitemap)
117141

118142
## ⭐️ Show your support
119143

src/vars.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,3 @@ export const DOMAIN = 'https://example.com';
55
export const OUT_DIR = 'build';
66

77
export const CONFIG_FILE = 'svelte-sitemap.cjs';
8-
9-
// export const OPTIONS: Options = {
10-
// domain: DOMAIN,
11-
// resetTime: false,
12-
// debug: false,
13-
// changeFreq: 'weekly'
14-
// };

0 commit comments

Comments
 (0)