Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoPennec committed Sep 27, 2019
1 parent 5a7ea28 commit e614073
Showing 1 changed file with 52 additions and 21 deletions.
73 changes: 52 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@

- [Installation](#installation)
- [Usage](#usage)
- [Sitemap Configuration](#sitemap-configuration)
- [Sitemap Index Configuration](#sitemap-index-configuration)
- [Sitemap Options](#sitemap-options)
- [Sitemap Index Options](#sitemap-index-options)
- [Routes Declaration](#routes-declaration)

## Installation

> npm install @nuxtjs/sitemap --save
```shell
npm install @nuxtjs/sitemap
```

or

> yarn add @nuxtjs/sitemap
```shell
yarn add @nuxtjs/sitemap
```

## Usage

Expand All @@ -53,14 +57,31 @@ or
- Add a custom configuration with the `sitemap` property.

You can set a single item of [sitemap](#sitemap-configuration) or [sitemap index](#sitemap-index-configuration) or an array of item:
You can set a single item of [sitemap](#sitemap-options) or [sitemap index](#sitemap-index-options) or an array of item.

```js
// Setup a simple sitemap.xml
// nuxt.config.js

{
modules: [
'@nuxtjs/sitemap'
],
sitemap: {
// custom configuration
}
}
```

### Setup a Sitemap

By default, the sitemap is setup to the following path: `/sitemap.xml`
All static routes (eg. `/pages/about.vue`) are automatically add to the sitemap, but you can exclude each of them with the [`exclude`](#exclude-optional---string-array) property.
For dynamic routes (eg. `/pages/_id.vue`), you have to declare them with the [`routes`](#routes-optional---array--function) property. This option can be an array or a function.

```js
// nuxt.config.js

{
sitemap: {
hostname: 'https://example.com',
gzip: true,
Expand All @@ -70,8 +91,9 @@ You can set a single item of [sitemap](#sitemap-configuration) or [sitemap index
],
routes: [
'/page/1',
'/page/2',
{
url: '/page/2',
url: '/page/3',
changefreq: 'daily',
priority: 1,
lastmod: '2017-06-30T13:30:00.000Z'
Expand All @@ -80,14 +102,17 @@ You can set a single item of [sitemap](#sitemap-configuration) or [sitemap index
}
```
### Setup a Sitemap Index
To declare a sitemap index and its linked sitemaps, use the [`sitemaps`](#sitemaps---array-of-object) property.
By default, the sitemap index is setup to the following path: `/sitemapindex.xml`
Each item of the `sitemaps` array can be setup with its own [sitemap options](#sitemap-options).
```js
// Setup a sitemap index and its linked sitemaps
// nuxt.config.js

{
modules: [
'@nuxtjs/sitemap'
],
sitemap: {
path: '/sitemapindex.xml',
hostname: 'https://example.com',
lastmod: '2017-06-30',
sitemaps: [
Expand All @@ -104,12 +129,15 @@ You can set a single item of [sitemap](#sitemap-configuration) or [sitemap index
}
```
### Setup a list of sitemaps
To declare a list of sitemaps, use an `array` to setup each sitemap with its own configuration.
You can combine sitemap and sitemap index configurations.
```js
// Setup several sitemaps
// nuxt.config.js

{
modules: [
'@nuxtjs/sitemap'
],
sitemap: [
{
path: '/sitemap-products.xml',
Expand All @@ -131,11 +159,11 @@ You can set a single item of [sitemap](#sitemap-configuration) or [sitemap index
## Sitemap Options
### `routes` - array or promise function
### `routes` (optional) - array | function
- Default: `[]` or [`generate.routes`](https://nuxtjs.org/api/configuration-generate#routes) value from your `nuxt.config.js`
The `routes` parameter follows the same way than the `generate` [configuration](https://nuxtjs.org/api/configuration-generate).
The `routes` parameter follows the same way than the `generate` [configuration](https://nuxtjs.org/api/configuration-generate#routes).
See as well the [routes declaration](#routes-declaration) examples below.
Expand All @@ -162,6 +190,8 @@ Defines how frequently should sitemap **routes** being updated (value in millise
Please note that after each invalidation, `routes` will be evaluated again. (See [routes declaration](#routes-declaration) section)
This option is enable only for the nuxt "universal" mode.
### `exclude` (optional) - string array
- Default: `[]`
Expand Down Expand Up @@ -263,7 +293,7 @@ The `defaults` parameter set the default options for all routes.
See available options: https://github.com/ekalinin/sitemap.js#usage
## Sitemap Index Configuration
## Sitemap Index Options
### `path` (optional) - string
Expand All @@ -279,7 +309,7 @@ Set the `hostname` value to each sitemap linked to its sitemap index.
- Default: `[]`
Array of [sitemap configuration](#sitemap-configuration]) linked to the sitemap index.
Array of [sitemap configuration](#sitemap-options]) linked to the sitemap index.
```js
// nuxt.config.js
Expand Down Expand Up @@ -393,12 +423,13 @@ const axios = require('axios')
}
}
}
```
## License
[MIT License](./LICENSE)
### Contributors
## Contributors
- [Nicolas Pennec](https://github.com/NicoPennec)
- [Pooya Parsa](https://github.com/pi0)

0 comments on commit e614073

Please sign in to comment.