Skip to content

Commit

Permalink
docs(readme): add config file instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
bartholomej committed Mar 4, 2022
1 parent fcf4f34 commit 25b9457
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
32 changes: 28 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,30 @@ yarn add svelte-sitemap --dev

## Usage

### CLI method (recommended)
### Config file method (recommended)

Create config file `svelte-sitemap.cjs` in the root of your project:

`svelte-sitemap.cjs`

```js
module.exports = {
domain: 'https://www.example.com'
// ...more options
};
```

Add `svelte-sitemap` as your postbuild script in `package.json` file:

`package.json`

```json
{
"postbuild": "npx svelte-sitemap"
}
```

### CLI method (Alternative 1)

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

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

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

### TypeScript or JavaScript method (optional)
### TypeScript or JavaScript method (Alternative 2)

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.

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

## Example

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

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

## ⭐️ Show your support

Expand Down
7 changes: 0 additions & 7 deletions src/vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ export const DOMAIN = 'https://example.com';
export const OUT_DIR = 'build';

export const CONFIG_FILE = 'svelte-sitemap.cjs';

// export const OPTIONS: Options = {
// domain: DOMAIN,
// resetTime: false,
// debug: false,
// changeFreq: 'weekly'
// };

0 comments on commit 25b9457

Please sign in to comment.