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

Commit 9690689

Browse files
committed
feat: support sitemap and commenting
1 parent 8e8c922 commit 9690689

File tree

4 files changed

+82
-44
lines changed

4 files changed

+82
-44
lines changed

docs/README.md

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,42 @@ module.exports = {
121121

122122
### modifyBlogPluginOptions
123123

124-
A function used to modify the default blog plugin options of [@vuepress/plugin-blog](https://vuepress-plugin-blog.ulivz.com/). It's common to use it to add apply custom [document classifiers](https://vuepress-plugin-blog.ulivz.com/#document-classifier). e.g.
124+
A function used to modify the default blog plugin options of [@vuepress/plugin-blog](https://vuepress-plugin-blog.ulivz.com/).
125+
126+
Here is the default blog plugin options:
127+
128+
```js
129+
{
130+
directories: [
131+
{
132+
id: 'post',
133+
dirname: '_posts',
134+
path: '/',
135+
// layout: 'IndexPost', defaults to `Layout.vue`
136+
itemLayout: 'Post',
137+
itemPermalink: '/:year/:month/:day/:slug',
138+
pagination: {
139+
lengthPerPage: 5,
140+
},
141+
},
142+
],
143+
frontmatters: [
144+
{
145+
id: "tag",
146+
keys: ['tag', 'tags'],
147+
path: '/tag/',
148+
// layout: 'Tag', defaults to `FrontmatterKey.vue`
149+
frontmatter: { title: 'Tag' },
150+
pagination: {
151+
lengthPerPage: 5
152+
}
153+
},
154+
]
155+
}
156+
```
157+
158+
159+
Adding apply custom [document classifiers](https://vuepress-plugin-blog.ulivz.com/guide/getting-started.html#document-classifier):
125160

126161
```js
127162
module.exports = {
@@ -146,53 +181,32 @@ module.exports = {
146181
}
147182
```
148183

149-
Here is the default blog plugin options:
150-
184+
Enabling commenting and sitemap:
151185
```js
152-
{
153-
directories: [
154-
{
155-
id: 'post',
156-
dirname: '_posts',
157-
path: '/',
158-
layout: 'IndexPost',
159-
itemLayout: 'Post',
160-
itemPermalink: '/:year/:month/:day/:slug',
161-
pagination: {
162-
perPagePosts: 5,
163-
},
164-
},
165-
{
166-
id: 'archive',
167-
dirname: '_archive',
168-
path: '/archive/',
169-
layout: 'IndexArchive',
170-
itemLayout: 'Post',
171-
itemPermalink: '/archive/:year/:month/:day/:slug',
172-
pagination: {
173-
perPagePosts: 5,
174-
},
175-
},
176-
],
177-
frontmatters: [
178-
{
179-
id: "tag",
180-
keys: ['tag', 'tags'],
181-
path: '/tag/',
182-
layout: 'Tags',
183-
frontmatter: { title: 'Tags' },
184-
itemlayout: 'Tag',
185-
pagination: {
186-
perPagePosts: 5
186+
module.exports = {
187+
themeConfig: {
188+
modifyBlogPluginOptions(blogPlugnOptions) {
189+
const sitemap = {
190+
hostname: 'https://yourdomain'
191+
}
192+
193+
const comment = {
194+
service: 'disqus',
195+
shortname: 'disqus-shortname',
196+
// service: 'vssue',
197+
// owner: 'You',
198+
// repo: 'Your repo',
199+
// clientId: 'Your clientId',
200+
// clientSecret: 'Your clientSecret',
187201
}
202+
203+
return { ...blogPluginOptions, sitemap, comment }
188204
},
189-
]
205+
},
190206
}
191207
```
192208

193-
**Also see:**
194-
195-
- [Document Classifier](https://vuepress-plugin-blog.ulivz.com/#document-classifier)
209+
Since many features are powered by the plugin, we suggest you to read the [documentation](https://vuepress-plugin-blog.ulivz.com/).
196210

197211

198212
### summary

example/.vuepress/config.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ module.exports = {
5454
],
5555
},
5656

57+
modifyBlogPluginOptions (blogPluginOptions) {
58+
const sitemap = {
59+
hostname: 'https://yourdomain'
60+
}
61+
62+
const comment = {
63+
service: 'disqus',
64+
shortname: 'vuepress-plugin-blog',
65+
// service: 'vssue',
66+
// owner: 'You',
67+
// repo: 'Your repo',
68+
// clientId: 'Your clientId',
69+
// clientSecret: 'Your clientSecret',
70+
}
71+
72+
return { ...blogPluginOptions, sitemap, comment }
73+
}
74+
5775
// paginationComponent: 'SimplePagination'
5876
},
5977
}

layouts/Post.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
<template>
22
<div id="vuperess-theme-blog__post-layout">
3-
<Content class="vuepress-blog-theme-content"/>
3+
<div class="vuepress-blog-theme-content">
4+
<Content/>
5+
<hr/>
6+
<Comment/>
7+
</div>
48
<Toc/>
59
</div>
610
</template>
711

812
<script>
913
import Toc from '@theme/components/Toc.vue'
14+
import { Comment } from '@vuepress/plugin-blog/lib/client/components'
1015
1116
export default {
1217
components: {
1318
Toc,
19+
Comment,
1420
},
1521
}
1622
</script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"author": "ulivz<[email protected]>",
2828
"license": "MIT",
2929
"dependencies": {
30-
"@vuepress/plugin-blog": "^1.2.5",
30+
"@vuepress/plugin-blog": "^1.5.0",
3131
"@vuepress/plugin-medium-zoom": "1.0.0",
3232
"@vuepress/plugin-nprogress": "1.0.0",
3333
"@vuepress/plugin-pwa": "1.0.0",

0 commit comments

Comments
 (0)