Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pooya Parsa
committed
Aug 28, 2017
0 parents
commit 7b52e52
Showing
12 changed files
with
7,523 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
# editorconfig.org | |||
root = true | |||
|
|||
[*] | |||
indent_size = 2 | |||
indent_style = space | |||
end_of_line = lf | |||
charset = utf-8 | |||
trim_trailing_whitespace = true | |||
insert_final_newline = true | |||
|
|||
[*.md] | |||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
module.exports = require('nuxt-module-builder/eslint') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
node_modules | |||
*.iml | |||
.idea | |||
*.log* | |||
.nuxt | |||
.vscode | |||
.DS_STORE | |||
coverage | |||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
# Change Log | |||
|
|||
All notable changes to this project will be documented in this file. | |||
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | |||
|
|||
<a name="0.0.3"></a> | |||
## [0.0.3](https://github.com/nuxt/modules/compare/@nuxtjs/sitemap@0.0.2...@nuxtjs/sitemap@0.0.3) (2017-08-03) | |||
|
|||
|
|||
### Bug Fixes | |||
|
|||
* **sitemap:** nuxt rc compability (#104) ([335ae7a](https://github.com/nuxt/modules/commit/335ae7a)) | |||
|
|||
|
|||
|
|||
|
|||
<a name="0.0.2"></a> | |||
## [0.0.2](https://github.com/nuxt/modules/compare/@nuxtjs/sitemap@0.0.1...@nuxtjs/sitemap@0.0.2) (2017-07-25) | |||
|
|||
|
|||
### Bug Fixes | |||
|
|||
* **sitemap:** refactor to fix production build ([27fdca8](https://github.com/nuxt/modules/commit/27fdca8)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
MIT License | |||
|
|||
Copyright (c) Nuxt Community | |||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to deal | |||
in the Software without restriction, including without limitation the rights | |||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the Software is | |||
furnished to do so, subject to the following conditions: | |||
|
|||
The above copyright notice and this permission notice shall be included in all | |||
copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,149 @@ | |||
# @nuxtjs/sitemap | |||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/sitemap/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/sitemap) | |||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/sitemap.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/sitemap) | |||
[![CircleCI](https://img.shields.io/circleci/project/github/nuxt-community/sitemap-module.svg?style=flat-square)](https://circleci.com/gh/nuxt-community/sitemap-module) | |||
[![Codecov](https://img.shields.io/codecov/c/github/nuxt-community/sitemap-module.svg?style=flat-square)](https://codecov.io/gh/nuxt-community/sitemap-module) | |||
[![Dependencies](https://david-dm.org/nuxt-community/sitemap-module/status.svg?style=flat-square)](https://david-dm.org/nuxt-community/sitemap-module) | |||
[![js-standard-style](https://cdn.rawgit.com/standard/standard/master/badge.svg)](http://standardjs.com) | |||
|
|||
> Automatically generate or serve dynamic [sitemap.xml](https://www.sitemaps.org/protocol.html) for Nuxt.js projects! | |||
[📖 **Release Notes**](./CHANGELOG.md) | |||
|
|||
Module based on the awesome [sitemap](https://github.com/ekalinin/sitemap.js) package ❤️ | |||
|
|||
## Setup | |||
- Add `@nuxtjs/sitemap` dependency using yarn or npm to your project | |||
- Add `@nuxtjs/sitemap` module to `nuxt.config.js` | |||
```js | |||
modules: [ | |||
'@nuxtjs/sitemap' | |||
] | |||
```` | |||
- Add additional options to `sitemap` section of `nuxt.config.js` to override defaults | |||
```js | |||
sitemap: { | |||
path: '/sitemap.xml', | |||
hostname: 'https://example.com', | |||
cacheTime: 1000 * 60 * 15, | |||
generate: false, // Enable me when using nuxt generate | |||
exclude: [ | |||
'/secret', | |||
'/admin/**' | |||
] | |||
routes: [ | |||
'/page/1', | |||
{ | |||
url: '/page/2', | |||
changefreq: 'daily', | |||
priority: 1, | |||
lastmodISO: '2017-06-30T13:30:00.000Z' | |||
} | |||
] | |||
} | |||
``` | |||
|
|||
## Options | |||
|
|||
### `exclude` | |||
The `exclude` parameter is an array of [glob patterns](https://github.com/isaacs/minimatch#features) to exclude static routes from the generated sitemap. | |||
|
|||
### `routes` | |||
The `routes` parameter follows the same way than the `generate` [configuration](https://nuxtjs.org/api/configuration-generate). | |||
|
|||
See as well the [routes](#routes-1) examples below. | |||
|
|||
### `path` | |||
- Default: `/sitemap.xml` | |||
|
|||
Where serve/generate sitemap file | |||
|
|||
### `hostname` | |||
- Default: | |||
- `hostname()` for generate mode | |||
- Dynamically based on request url for middleware mode | |||
|
|||
This values is **mandatory** for generation sitemap file, and you should explicitly provide it for generate mode. | |||
|
|||
### `generate` | |||
- Default: `false` | |||
|
|||
Generates static sitemap file during build/generate instead of serving using middleware. | |||
|
|||
### `cacheTime` | |||
- Default: `1000 * 60 * 15` (15 Minutes) | |||
|
|||
Defines how frequently should sitemap **routes** being updated. | |||
This option is only effective when `generate` is `false`. | |||
Please note that after each invalidation, `routes` will be evaluated again. (See [routes](#routes-1) section) | |||
|
|||
## Routes | |||
|
|||
Dynamic routes are ignored by the sitemap module. | |||
|
|||
Example: | |||
|
|||
``` | |||
-| pages/ | |||
---| index.vue | |||
---| users/ | |||
-----| _id.vue | |||
``` | |||
|
|||
If you want the module to add routes with dynamic params, you need to set an array of dynamic routes. | |||
|
|||
We add routes for `/users/:id` in `nuxt.config.js`: | |||
|
|||
```js | |||
sitemap: { | |||
routes: [ | |||
'/users/1', | |||
'/users/2', | |||
'/users/3' | |||
] | |||
} | |||
``` | |||
|
|||
### Function which returns a Promise | |||
|
|||
`nuxt.config.js` | |||
```js | |||
const axios = require('axios') | |||
module.exports = { | |||
sitemap: { | |||
routes () { | |||
return axios.get('https://jsonplaceholder.typicode.com/users') | |||
.then(res => res.data.map(user => '/users/' + user.username)) | |||
} | |||
} | |||
} | |||
``` | |||
|
|||
### Function with a callback | |||
|
|||
`nuxt.config.js` | |||
```js | |||
const axios = require('axios') | |||
module.exports = { | |||
sitemap: { | |||
routes (callback) { | |||
axios.get('https://jsonplaceholder.typicode.com/users') | |||
.then(res => { | |||
let routes = res.data.map(user => '/users/' + user.username) | |||
callback(null, routes) | |||
}) | |||
.catch(callback) | |||
} | |||
} | |||
} | |||
``` | |||
|
|||
### Contributors | |||
- [Nicolas PENNEC](https://github.com/NicoPennec) | |||
- [Pooya Parsa](https://github.com/pi0) | |||
|
|||
## License | |||
|
|||
[MIT License](./LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
{ | |||
"name": "@nuxtjs/sitemap-module", | |||
"version": "0.0.3", | |||
"description": "Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects", | |||
"license": "MIT", | |||
"contributors": [ | |||
{ | |||
"name": "Nicolas Pennec" | |||
}, | |||
{ | |||
"name": "Pooya Parsa" | |||
} | |||
], | |||
"main": "dist/index.js", | |||
"repository": "https://github.com/nuxt-community/sitemap-module", | |||
"publishConfig": { | |||
"access": "public" | |||
}, | |||
"scripts": { | |||
"build": "nuxt-module", | |||
"watch": "nuxt-module --watch", | |||
"lint": "eslint lib src test", | |||
"lint-fix": "eslint --fix lib src test", | |||
"test": "NODE_ENV=test npm run build && npm run lint && jest", | |||
"release": "standard-version && git push --follow-tags && npm publish", | |||
"prepare": "npm run test && npm run build" | |||
}, | |||
"eslintIgnore": [ | |||
"*.template.*" | |||
], | |||
"files": [ | |||
"lib", | |||
"src", | |||
"dist" | |||
], | |||
"jest": { | |||
"testEnvironment": "node", | |||
"coverageDirectory": "./coverage/", | |||
"collectCoverage": true, | |||
"collectCoverageFrom": [ | |||
"lib", | |||
"src" | |||
] | |||
}, | |||
"dependencies": { | |||
"async-cache": "^1.1.0", | |||
"fs-extra": "^4.0.0", | |||
"is-https": "^1.0.0", | |||
"lodash": "^4.17.4", | |||
"minimatch": "^3.0.4", | |||
"pify": "^3.0.0", | |||
"sitemap": "^1.13.0" | |||
}, | |||
"devDependencies": { | |||
"nuxt-module-builder": "^0.0.2" | |||
} | |||
} |
Oops, something went wrong.