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

Commit e09658f

Browse files
committed
2 parents 89dbddb + 65c904e commit e09658f

File tree

4 files changed

+72
-33
lines changed

4 files changed

+72
-33
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: ulivz # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4+
patreon: ulivz # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with a single custom sponsorship URL

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# @vuepress/plugin-blog
22

3-
> Official blog theme for VuePress.
3+
> Official blog plugin for VuePress.
44
5-
Note that this plug-in has been deeply integrated into [@vuepress/theme-blog](https://github
6-
.com/ulivz/vuepress-theme-blog).
5+
Note that this plugin has been deeply integrated into [@vuepress/theme-blog](https://github.com/ulivz/vuepress-theme-blog).
76

87
## Install
98

docs/.vuepress/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
module.exports = {
22
title: '@vuepress/plugin-blog',
33
description: 'Offical blog plugin for VuePress',
4+
themeConfig: {
5+
repo: 'ulivz/vuepress-plugin-blog',
6+
}
47
}
8+

docs/README.md

Lines changed: 54 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ sidebar: auto
44

55
# @vuepress/plugin-blog
66

7-
> Official blog theme for VuePress.
7+
> Official blog plugin for VuePress.
88
9-
Note that this plug-in has been deeply integrated into [@vuepress/theme-blog](https://github.com/ulivz/vuepress-theme-blog).
9+
Note that this plugin has been deeply integrated into [@vuepress/theme-blog](https://github.com/ulivz/vuepress-theme-blog).
1010

1111
## Install
1212

@@ -26,19 +26,22 @@ module.exports = {
2626

2727
## Tutorials
2828

29-
### Classifier
29+
### Document Classifier
3030

31-
This plugin creates a concept named `classifier`. All files in a directory (e.g. `_post`) should be the
32-
same classification, all pages containing the same specific frontmatter key value (e.g. `tag: js`) can also be a
33-
classification.
31+
`Document classifier` is a set of functions that can classify pages with the same characteristics. For a blog developer, the same characteristics may exist between different pages as follows:
3432

35-
So there are two different types of classification. Of course, both of them may be related to another common
36-
requirement, `pagination`. Next, let's take a look at the benefits of this plugin from the shallow to the deep.
33+
- Pages put in a directory (e.g. `_post`)
34+
- Pages containing the same specific frontmatter key value (e.g. `tag: js`).
35+
36+
Of course, both of them may be related to another common
37+
requirement, `pagination`.
38+
39+
So, how to combine them skillfully? Next, let's take a look at how this plugin solve these problems.
3740

3841

3942
### Directory Classifier
4043

41-
Directory Classifier, that means the classification of source files in a same directory.
44+
Directory Classifier, that classifies the source pages placed in a same directory.
4245

4346
Suppose you have the following files structure:
4447

@@ -81,7 +84,7 @@ layout:
8184

8285
| url | layout |
8386
|---|---|
84-
| `/` | `IndexPost` |
87+
| `/` | `IndexPost` / `Layout` |
8588
| `/2018/04/04/intro-to-vuepress/` | `Post` |
8689
| `/2019/06/08/intro-to-vuepress-next/` | `Post` |
8790

@@ -142,7 +145,7 @@ The default value of `itemPermalink` is `'/:year/:month/:day/:slug'`.
142145
As your blog articles grew more and more, you began to have the need for paging. By default, this plugin integrates a
143146
very powerful pagination system that allows you to access paging functions with simple configuration.
144147

145-
By default, the plugin assumes that the number of pages per page is `10`. you can also modify it like this:
148+
By default, the plugin assumes that the max number of pages per page is `10`. you can also modify it like this:
146149

147150
```diff
148151
// .vuepress/config.js
@@ -174,16 +177,20 @@ When the `perPagePosts` is set to `2`, this plugin will help you generate the fo
174177

175178
| url | layout |
176179
|---|---|
177-
| `/` | `IndexPost / Layout` |
178-
| `/page/2/` (New) | `DirectoryPagination / Layout` |
180+
| `/` | `IndexPost` / `Layout` |
181+
| `/page/2/` (New) | `DirectoryPagination` / `Layout` |
179182
| `/2019/06/08/a/` | `Post` |
180183
| `/2019/06/08/b/` | `Post` |
181184
| `/2018/06/08/c/` | `Post` |
182185

186+
::: tip
187+
`DirectoryPagination / Layout` means that the layout component will be downgraded to `Layout` when `DirectoryPagination` layout doesn't exist.
188+
:::
189+
183190
So how to get the matched pages in the layout component? In fact, it will be much simpler than you think.
184191

185-
If you visit `/`, current page leverages layout `IndexPost`, in this layout component, you just need to use `this
186-
.$pagination.pages` to get the matched pages, in the above example, the actual value of `this.$pagination.pages` will
192+
If you visit `/`, current page leverages layout `IndexPost`. In this layout component, you just need to use
193+
`this.$pagination.pages` to get the matched pages. In the above example, the actual value of `this.$pagination.pages` will
187194
be:
188195

189196
```json
@@ -193,27 +200,27 @@ If you visit `/`, current page leverages layout `IndexPost`, in this layout comp
193200
]
194201
```
195202

196-
If you visit `/`, current page leverages layout `DirectoryPagination`, you can also use `this
197-
.$pagination.pages` to access it:
203+
If you visit `/`, current page leverages layout `DirectoryPagination`, you can also use
204+
`this.$pagination.pages` to access it:
198205

199206
```json
200207
[
201208
{ "relativePath": "_posts/2019-6-8-c.md", "path": "/2019/06/08/c/" ... },
202209
]
203210
```
204211

205-
Isn't a very natural experiences? You just need to care about the style of your layout component, not the complicated and boring logic behind it.
212+
Isn't this very natural experience? You just need to care about the style of your layout component, not the complicated and boring logic behind it.
206213

207214

208215
::: tip
209-
To save the length of docs, we omitted the data structure of `$page` object. you can get more information about
216+
To save the length of docs, we omitted the data structure of the `$page` object. You can get more information about
210217
the data structure of `$page` at the [official documentation](https://v1.vuepress.vuejs.org/guide/global-computed.html#page).
211218
:::
212219

213220

214221
### Frontmatter Classifier
215222

216-
Frontmatter Classifier, that is the classification of pages that have the same frontmatter key values.
223+
Frontmatter Classifier, which classifies pages that have the same frontmatter key values.
217224

218225
Suppose you have three pages:
219226

@@ -258,22 +265,22 @@ module.exports = {
258265
// Layout of the `entry page`
259266
layout: 'Tag',
260267
},
261-
]
268+
]
262269
}]
263270
]
264271
}
265272
```
266273

267-
Then the plugin will help you to generate following extra pages, and automatically leverage corresponding
268-
layout:
274+
Then the plugin will help you to generate the following extra pages, and automatically leverage
275+
the corresponding layout:
269276

270277
| url | layout |
271278
|---|---|
272279
| `/tag/` | `Tag` |
273-
| `/tag/vue/` | `FrontmatterClassifier` |
274-
| `/tag/js/` | `FrontmatterClassifier` |
280+
| `/tag/vue/` | `FrontmatterPagination` / `Layout` |
281+
| `/tag/js/` | `FrontmatterPagination` / `Layout` |
275282

276-
In `Tags` component, you can use `this.$tag.list` to get the tag list. the value would be like:
283+
In the `Tags` component, you can use `this.$tag.list` to get the tag list. The value would be like:
277284

278285
```json
279286
[
@@ -295,9 +302,8 @@ In `Tags` component, you can use `this.$tag.list` to get the tag list. the value
295302
]
296303
```
297304

298-
In `FrontmatterClassifier` component, you can use `this.$pagination.pages` to get the matched pages in current tag
299-
classification. And what is wonderful is that a you don't nned to card about where you are, and you'll get a very
300-
natural experiences:
305+
In the `FrontmatterPagination` component, you can use `this.$pagination.pages` to get the matched pages in current tag
306+
classification:
301307

302308
- If you visit `/tag/vue/`, the `this.$pagination.pages` will be:
303309

@@ -317,8 +323,26 @@ natural experiences:
317323
```
318324

319325

326+
## Examples
320327

328+
Actually, there are only 2 necessary layout components to create a blog theme:
329+
330+
- Layout
331+
- Post
332+
- Tag (Only required when you set up a `tag` frontmatter classification.)
333+
334+
Here is [live example](https://github.com/ulivz/70-lines-of-vuepress-blog-theme) that implements a functionally qualified VuePress theme in around 70 lines.
321335

322336
## Options
323337

324-
###
338+
### directories
339+
340+
> TODO, contribution welcome.
341+
342+
### frontmatters
343+
344+
> TODO, contribution welcome.
345+
346+
347+
348+

0 commit comments

Comments
 (0)