|
1 | | -# vuepress-theme-blogging |
| 1 | +--- |
| 2 | +sidebar: auto |
| 3 | +--- |
2 | 4 |
|
3 | | -[](https://npmjs.com/package/vuepress-theme-blogging) [](https://npmjs.com/package/vuepress-theme-blogging) [](https://circleci.com/gh/ulivz/vuepress-theme-blogging/tree/master) |
| 5 | +# @vuepress/plugin-blog |
| 6 | + |
| 7 | +> Default blog theme for VuePress |
4 | 8 |
|
5 | 9 | ## Install |
6 | 10 |
|
7 | 11 | ```bash |
8 | | -npm i vuepress-theme-blogging |
| 12 | +yarn add @vuepress/theme-blog -D |
| 13 | +# OR npm install @vuepress/theme-blog -D |
9 | 14 | ``` |
10 | 15 |
|
11 | 16 | ## Usage |
12 | 17 |
|
13 | 18 | ```js |
14 | | -const vuepressThemeBlogging = require('vuepress-theme-blogging') |
| 19 | +// .vuepress/config.js |
| 20 | +module.exports = { |
| 21 | + theme: '@vuepress/blog', |
| 22 | + themeConfig: { |
| 23 | + // Please keep looking down to see the available options. |
| 24 | + } |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +## Options |
| 29 | + |
| 30 | +### nav |
| 31 | + |
| 32 | +- 类型: `Array<{ text: string, link: string }>` |
| 33 | +- 默认值: `undefined` |
15 | 34 |
|
16 | | -vuepressThemeBlogging() |
17 | | -//=> foo |
| 35 | +e.g. |
| 36 | + |
| 37 | +```js |
| 38 | +module.exports = { |
| 39 | + themeConfig: { |
| 40 | + nav: [ |
| 41 | + { |
| 42 | + text: 'Home', |
| 43 | + link: '/', |
| 44 | + }, |
| 45 | + { |
| 46 | + text: 'Archive', |
| 47 | + link: '/archive/', |
| 48 | + }, |
| 49 | + { |
| 50 | + text: 'Tags', |
| 51 | + link: '/tag/', |
| 52 | + }, |
| 53 | + ], |
| 54 | + }, |
| 55 | +} |
18 | 56 | ``` |
| 57 | + |
| 58 | +### footer |
| 59 | + |
| 60 | +#### footer.contact |
| 61 | + |
| 62 | + |
| 63 | +- 类型: `Array<{ type: ContactType, link: string }>` |
| 64 | +- 默认值: `undefined` |
| 65 | + |
| 66 | +Contact information, displayed on the left side of footer. |
| 67 | + |
| 68 | +```js |
| 69 | +module.exports = { |
| 70 | + themeConfig: { |
| 71 | + footer: { |
| 72 | + contact: [ |
| 73 | + { |
| 74 | + type: 'github', |
| 75 | + link: 'https://github.com/vuejs/vuepress', |
| 76 | + }, |
| 77 | + { |
| 78 | + type: 'twitter', |
| 79 | + link: 'https://github.com/vuejs/vuepress', |
| 80 | + }, |
| 81 | + ], |
| 82 | + }, |
| 83 | + }, |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +For now `ContactType` supports following enums: |
| 88 | + |
| 89 | +- github |
| 90 | +- facebook |
| 91 | +- twitter |
| 92 | + |
| 93 | +::: tip |
| 94 | +Welcome contribution of adding more built-in contact type. |
| 95 | +::: |
| 96 | + |
| 97 | +#### footer.copyright |
| 98 | + |
| 99 | +Copyright information, displayed on the right side of footer. |
| 100 | + |
| 101 | +```js |
| 102 | +module.exports = { |
| 103 | + themeConfig: { |
| 104 | + footer: { |
| 105 | + copyright: [ |
| 106 | + { |
| 107 | + text: 'Privacy Policy', |
| 108 | + link: 'https://policies.google.com/privacy?hl=en-US', |
| 109 | + }, |
| 110 | + { |
| 111 | + text: 'MIT Licensed | Copyright © 2018-present Vue.js', |
| 112 | + link: '', |
| 113 | + }, |
| 114 | + ], |
| 115 | + }, |
| 116 | + }, |
| 117 | +} |
| 118 | +``` |
| 119 | + |
| 120 | +### modifyBlogPluginOptions |
| 121 | + |
| 122 | +A function used to modify the default blog plugin options. It's common to used it to add custom classifiers. e.g. |
| 123 | + |
| 124 | +```js |
| 125 | +module.exports = { |
| 126 | + themeConfig: { |
| 127 | + modifyBlogPluginOptions(blogPlugnOptions) { |
| 128 | + const writingDirectoryClassifier = { |
| 129 | + id: 'writing', |
| 130 | + dirname: '_writings', |
| 131 | + path: '/writings/', |
| 132 | + layout: 'IndexWriting', |
| 133 | + itemLayout: 'Writing', |
| 134 | + itemPermalink: '/writings/:year/:month/:day/:slug', |
| 135 | + pagination: { |
| 136 | + perPagePosts: 5, |
| 137 | + }, |
| 138 | + } |
| 139 | + |
| 140 | + blogPlugnOptions.directories.push(writingDirectoryClassifier) |
| 141 | + return blogPlugnOptions |
| 142 | + }, |
| 143 | + }, |
| 144 | +} |
| 145 | +``` |
| 146 | + |
| 147 | +Here is the default blog plugin options: |
| 148 | + |
| 149 | +```js |
| 150 | +{ |
| 151 | + directories: [ |
| 152 | + { |
| 153 | + id: 'post', |
| 154 | + dirname: '_posts', |
| 155 | + path: '/', |
| 156 | + layout: 'IndexPost', |
| 157 | + itemLayout: 'Post', |
| 158 | + itemPermalink: '/:year/:month/:day/:slug', |
| 159 | + pagination: { |
| 160 | + perPagePosts: 5, |
| 161 | + }, |
| 162 | + }, |
| 163 | + { |
| 164 | + id: 'archive', |
| 165 | + dirname: '_archive', |
| 166 | + path: '/archive/', |
| 167 | + layout: 'IndexArchive', |
| 168 | + itemLayout: 'Post', |
| 169 | + itemPermalink: '/archive/:year/:month/:day/:slug', |
| 170 | + pagination: { |
| 171 | + perPagePosts: 5, |
| 172 | + }, |
| 173 | + }, |
| 174 | + ], |
| 175 | + frontmatters: [ |
| 176 | + { |
| 177 | + id: "tag", |
| 178 | + keys: ['tag', 'tags'], |
| 179 | + path: '/tag/', |
| 180 | + layout: 'Tags', |
| 181 | + frontmatter: { title: 'Tags' }, |
| 182 | + itemlayout: 'Tag', |
| 183 | + pagination: { |
| 184 | + perPagePosts: 5 |
| 185 | + } |
| 186 | + }, |
| 187 | + ] |
| 188 | +} |
| 189 | +``` |
| 190 | + |
0 commit comments