Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,18 @@ Pagination config for all directories and frontmatters.
- Required: `false`

Please head to [Pagination Config](../pagination/README.md#config) section to get all available options.

## sitemap

- Type: `object`
- Default: `{}`
- Required: `false`

It will be enabled when `hostname` is provided. e.g.

```js
{
hostname: 'https://yourdomain'
}
```
The 404 page is excluded by default. Further options, please head to [vuepress-plugin-sitemap](https://github.com/ekoeryanto/vuepress-plugin-sitemap#options).
3 changes: 3 additions & 0 deletions examples/blog/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ module.exports = {
],
globalPagination: {
lengthPerPage: 5
},
sitemap: {
hostname: 'https://yourdomain'
}
}],
],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"author": "ULIVZ <chl814@foxmail.com>",
"license": "MIT",
"dependencies": {
"vuejs-paginate": "^2.1.0"
"vuejs-paginate": "^2.1.0",
"vuepress-plugin-forked-sitemap": "^0.0.1"
},
"devDependencies": {
"concurrently": "^4.1.0",
Expand Down
13 changes: 13 additions & 0 deletions src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
paginations,
} = handleOptions(options, ctx)

/**
* Leverage other plugins
*/
let plugins

if (options.sitemap && options.sitemap.hostname) {
const sitemapOptions = { ...options.sitemap, exclude: ['/404.html'] }
// Temporarily use a fork of vuepress-plugin-sitemap. Should switch back when it release the next version.
plugins = [['vuepress-plugin-forked-sitemap', sitemapOptions], ['@vuepress/last-updated']]
}

return {
name: 'vuepress-plugin-blog',

Expand Down Expand Up @@ -195,6 +206,8 @@ export default ${serializePaginations(ctx.serializedPaginations, [
path.resolve(__dirname, '../client/classification.js'),
path.resolve(__dirname, '../client/pagination.js'),
],

plugins
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/node/interface/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ export interface FrontmatterClassifier {
export interface BlogPluginOptions {
directories: DirectoryClassifier[];
frontmatters: FrontmatterClassifier[];
globalPagination: PaginationConfig
globalPagination: PaginationConfig;
sitemap:any
}