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

Commit 4fc0f73

Browse files
committed
docs: enhance client api
1 parent d0345fc commit 4fc0f73

File tree

5 files changed

+113
-45
lines changed

5 files changed

+113
-45
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
{ text: 'Guide', link: '/guide/' },
88
{ text: 'Config', link: '/config/' },
99
{ text: 'Pagination', link: '/pagination/' },
10+
{ text: 'Client API', link: '/client-api/' },
1011
{ text: 'Components', link: '/components/' },
1112
],
1213
sidebarDepth: 3,

docs/client-api/README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
sidebar: auto
3+
---
4+
5+
# Client API
6+
7+
::: tip TIP
8+
We strongly recommend that you read the [Getting Started](../guide/getting-started.md) section before using this plugin.
9+
:::
10+
11+
## $pagination
12+
13+
### $pagination.pages
14+
15+
Matched pages for current route. example:
16+
17+
```json
18+
[
19+
{ "relativePath": "b.md", "path": "/b.html" ... },
20+
{ "relativePath": "a.md", "path": "/a.html" ... },
21+
]
22+
```
23+
24+
### $pagination.length
25+
26+
Length of current paginations.
27+
28+
### $pagination.hasPrev
29+
30+
Whether previous pagination page exists.
31+
32+
### $pagination.prevLink
33+
34+
Link of previous pagination page.
35+
36+
### $pagination.hasNext
37+
38+
Whether next pagination page exists.
39+
40+
### $pagination.nextLink
41+
42+
Link of next pagination page.
43+
44+
### $pagination.getSpecificPageLink
45+
46+
Get specific pagination page via page number.
47+
48+
::: tip TIP
49+
You can use this function to custom the pagination component as the internal
50+
[`<Pagnination />`](../components/#pagination) component.
51+
:::
52+
53+
54+
## `$${FCID}`
55+
56+
FCID, i.e the id of [Frontmatter Classifier](../guide/getting-started.md#frontmatter-classifier), if you create a
57+
[Frontmatter Classifier](../guide/getting-started.md#frontmatter-classifier) as follows:
58+
59+
```js
60+
module.exports = {
61+
plugins: [
62+
[
63+
'@vuepress/blog',
64+
{
65+
frontmatters: [
66+
{
67+
// Unique ID of current classification
68+
id: 'tag',
69+
// Decide that the frontmatter keys will be grouped under this classification
70+
keys: ['tag'],
71+
// Path of the `entry page` (or `list page`)
72+
path: '/tag/',
73+
// Layout of the `entry page`
74+
layout: 'Tag',
75+
},
76+
],
77+
},
78+
],
79+
],
80+
}
81+
```
82+
83+
Then this plugin will inject a `$tag` object to the prototype of Vue, so you can use it directly at your
84+
layout component (`<Tag />`).
85+
86+
### `$${FCID}.list`
87+
88+
Get the list of matched frontmatter classifier types.
89+
90+
The interface is as follows:
91+
92+
```typescript
93+
type FCID = Array<{
94+
name: string;
95+
path: string;
96+
pages: Array<VuePressPage>;
97+
}>
98+
```
99+
100+
You can re-read the [Frontmatter Classifier](../guide/getting-started.md#frontmatter-classifier) to see the live
101+
example of `tag`.

docs/components/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ In order to better enjoy the convenience of this plugin, the plugin provides som
88

99
## `<SimplePagination>`
1010

11-
- Using it at your layout component:
11+
- Source Code:
12+
[SimplePagination.vue](https://github.com/ulivz/vuepress-plugin-blog/blob/master/src/client/components/SimplePagination.vue)
13+
- Usage:
1214

1315
```vue
1416
<template>
@@ -36,7 +38,8 @@ default colors of this component.
3638

3739
## `<Pagination>`
3840

39-
- Using it at your layout component:
41+
- Source Code: [Pagination.vue](https://github.com/ulivz/vuepress-plugin-blog/blob/master/src/client/components/Pagination.vue)
42+
- Usage:
4043

4144
```vue
4245
<template>

docs/guide/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ the corresponding layout:
257257
| `/tag/vue/` | `FrontmatterPagination` / `Layout` |
258258
| `/tag/js/` | `FrontmatterPagination` / `Layout` |
259259

260-
In the `Tags` component, you can use `this.$tag.list` to get the tag list. The value would be like:
260+
In the `<Tag />` component, you can use `this.$tag.list` to get the tag list. The value would be like:
261261

262262
```json
263263
[

docs/pagination/README.md

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
sidebar: auto
33
---
44

5-
# Pagination
5+
# Pagination Config
66

77
::: tip TIP
88
We strongly recommend that you read the [Getting Started](../guide/getting-started.md) section before using this plugin.
99
:::
1010

11-
## Config
12-
13-
### sorter
11+
## sorter
1412

1513
- Type: string
1614
- Default: `See Below`
@@ -25,21 +23,21 @@ function sorter(prev: VuePressPage, next: VuePressPage){
2523
},
2624
```
2725

28-
### lengthPerPage
26+
## lengthPerPage
2927

3028
- Type: string
3129
- Default: `10`
3230

3331
Maximum number of posts per page.
3432

35-
### layout
33+
## layout
3634

3735
- Type: string
3836
- Default: `DirectoryPagination || Layout`
3937

4038
Layout for pagination page (Except the index page.)
4139

42-
### getPaginationPageUrl
40+
## getPaginationPageUrl
4341

4442
- Type: string
4543
- Default: `See Below`
@@ -62,39 +60,4 @@ function getPaginationPageUrl(index) {
6260
`/tag/js/`)
6361

6462

65-
## Client API
66-
67-
### $pagination
68-
69-
#### $pagination.pages
70-
71-
Matched pages for current route.
72-
73-
#### $pagination.length
74-
75-
Length of current paginations.
76-
77-
#### $pagination.hasPrev
78-
79-
Whether previous pagination page exists.
80-
81-
#### $pagination.prevLink
82-
83-
Link of previous pagination page.
84-
85-
#### $pagination.hasNext
86-
87-
Whether next pagination page exists.
88-
89-
#### $pagination.nextLink
90-
91-
Link of next pagination page.
92-
93-
#### $pagination.getSpecificPageLink
94-
95-
Get specific pagination page via page number.
96-
97-
98-
99-
10063

0 commit comments

Comments
 (0)