Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit c780100

Browse files
feat: intergrate sitemap (#28)
1 parent dddb231 commit c780100

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

Diff for: docs/config/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,18 @@ Pagination config for all directories and frontmatters.
188188
- Required: `false`
189189

190190
Please head to [Pagination Config](../pagination/README.md#config) section to get all available options.
191+
192+
## sitemap
193+
194+
- Type: `object`
195+
- Default: `{}`
196+
- Required: `false`
197+
198+
It will be enabled when `hostname` is provided. e.g.
199+
200+
```js
201+
{
202+
hostname: 'https://yourdomain'
203+
}
204+
```
205+
The 404 page is excluded by default. Further options, please head to [vuepress-plugin-sitemap](https://github.com/ekoeryanto/vuepress-plugin-sitemap#options).

Diff for: examples/blog/.vuepress/config.js

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ module.exports = {
4141
],
4242
globalPagination: {
4343
lengthPerPage: 5
44+
},
45+
sitemap: {
46+
hostname: 'https://yourdomain'
4447
}
4548
}],
4649
],

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"author": "ULIVZ <[email protected]>",
3030
"license": "MIT",
3131
"dependencies": {
32-
"vuejs-paginate": "^2.1.0"
32+
"vuejs-paginate": "^2.1.0",
33+
"vuepress-plugin-forked-sitemap": "^0.0.1"
3334
},
3435
"devDependencies": {
3536
"concurrently": "^4.1.0",

Diff for: src/node/index.ts

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ module.exports = (options: BlogPluginOptions, ctx: VuePressContext) => {
3232
paginations,
3333
} = handleOptions(options, ctx)
3434

35+
/**
36+
* Leverage other plugins
37+
*/
38+
let plugins
39+
40+
if (options.sitemap && options.sitemap.hostname) {
41+
const sitemapOptions = { ...options.sitemap, exclude: ['/404.html'] }
42+
// Temporarily use a fork of vuepress-plugin-sitemap. Should switch back when it release the next version.
43+
plugins = [['vuepress-plugin-forked-sitemap', sitemapOptions], ['@vuepress/last-updated']]
44+
}
45+
3546
return {
3647
name: 'vuepress-plugin-blog',
3748

@@ -195,6 +206,8 @@ export default ${serializePaginations(ctx.serializedPaginations, [
195206
path.resolve(__dirname, '../client/classification.js'),
196207
path.resolve(__dirname, '../client/pagination.js'),
197208
],
209+
210+
plugins
198211
}
199212
}
200213

Diff for: src/node/interface/Options.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ export interface FrontmatterClassifier {
8383
export interface BlogPluginOptions {
8484
directories: DirectoryClassifier[];
8585
frontmatters: FrontmatterClassifier[];
86-
globalPagination: PaginationConfig
86+
globalPagination: PaginationConfig;
87+
sitemap:any
8788
}

0 commit comments

Comments
 (0)