Skip to content

Commit 98ddcb5

Browse files
authored
feat: add docs (#10)
1 parent 9f9191e commit 98ddcb5

22 files changed

+663
-136
lines changed

.github/workflows/deploy.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- 'v**'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install Node.js
20+
uses: actions/setup-node@v3
21+
with:
22+
node-version: '18'
23+
registry-url: https://registry.npmjs.org/
24+
25+
- name: Install pnpm
26+
uses: pnpm/action-setup@v2
27+
with:
28+
version: latest
29+
30+
- name: Install dependencies
31+
run: pnpm i --frozen-lockfile
32+
33+
- name: Build
34+
run: pnpm run build:docs
35+
36+
- name: Deploy
37+
uses: JamesIves/github-pages-deploy-action@v4
38+
with:
39+
GITHUB_TOKEN: ${{ secrets.PAGE }}
40+
branch: gh-pages
41+
folder: dist
42+
clean: true

README.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
> A blog theme based on vitepress
44
5-
Live Demo: [My Blog](https://ououe.com)
5+
[Documentation](https://tolking.github.io/vitepress-theme-ououe)
66

7-
![demo](./examples/public/vitepress-theme-ououe.jpg)
7+
![image](./docs/public/vitepress-theme-ououe.jpg)
88

99
## Install
1010

@@ -33,7 +33,3 @@ export default defineConfigWithTheme<Theme>({
3333
},
3434
})
3535
```
36-
37-
## Config
38-
39-
[Refer to type file](./src/types/theme.ts)

examples/.vitepress/config.ts renamed to docs/.vitepress/config.ts

+28-9
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,31 @@ import { defineConfigWithTheme } from 'vitepress'
33
import type { Theme } from '../../src/types'
44

55
export default defineConfigWithTheme<Theme>({
6-
title: 'My Site',
7-
description: 'This is my site',
8-
// srcDir: 'posts',
9-
// base: '/base/',
6+
title: 'vitepress-theme-ououe',
7+
description: 'A blog theme based on vitepress',
8+
outDir: '../dist',
109
cleanUrls: true,
1110
lastUpdated: true,
12-
11+
lang: 'zn-CN',
12+
head: [
13+
['link', { rel: 'icon', href: '/favicon.ico' }],
14+
['meta', { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge,chrome=1' }],
15+
['meta', { name: 'renderer', content: 'webkit' }],
16+
['meta', { name: 'force-rendering', content: 'webkit' }],
17+
['meta', { name: 'applicable-device', content: 'pc,mobile' }],
18+
['meta', { name: 'author', content: 'tolking <[email protected]>' }],
19+
],
20+
// locales: {
21+
// root: {
22+
// label: 'English',
23+
// lang: 'en'
24+
// },
25+
// zh: {
26+
// label: '简体中文',
27+
// lang: 'zh-CN',
28+
// description: '为 vuepress 制作的一款主题'
29+
// }
30+
// },
1331
themeConfig: {
1432
// logo: {
1533
// src: 'https://avatars.githubusercontent.com/u/23313167?v=4',
@@ -34,12 +52,13 @@ export default defineConfigWithTheme<Theme>({
3452
},
3553
],
3654
pagination: {
37-
// prev: "<-",
38-
// next: "->",
55+
prev: '<-',
56+
next: '->',
3957
// match: (path) => /^\/($|index|page-)/.test(path),
58+
sort: (a, b) => a.index - b.index,
4059
// filter: (page) => page.home,
4160
},
42-
// excerpt: '<!-- more -->',
61+
excerpt: '<!-- more -->',
4362
createTime: {
4463
text: 'Create Time',
4564
format: (date) => new Date(date).toLocaleDateString(),
@@ -54,7 +73,7 @@ export default defineConfigWithTheme<Theme>({
5473
// { text: "Home", link: "/" },
5574
// { text: "GitHub", link: "https://github.com/tolking/vitepress-theme-ououe" },
5675
// ],
57-
copyright: 'copyright © 2023',
76+
copyright: 'tolking © 2023',
5877
},
5978
search: {
6079
provider: 'local',
File renamed without changes.
File renamed without changes.

examples/[page].paths.ts renamed to docs/[page].paths.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
paths() {
55
const limit = 12 // Item count of each page
66
const files = fs
7-
.readdirSync('examples/posts')
7+
.readdirSync('docs/posts')
88
.filter((file) => !/^\[[^]*]\]\./.test(file))
99
const total = Math.ceil(files.length / limit)
1010

File renamed without changes.

docs/posts/config.md

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
---
2+
title: 主题配置
3+
descript: 如何配置博客的分页
4+
date: 2023-08-19
5+
image: https://picsum.photos/536/354?random=10
6+
index: 10
7+
tags:
8+
- reference
9+
- config
10+
categories:
11+
- docs
12+
---
13+
14+
主题的所有配置项
15+
16+
<!-- more -->
17+
18+
## Options
19+
20+
### logo
21+
22+
- Type: `string` | `object`
23+
24+
网站的 logo 图片
25+
26+
```ts
27+
logo: 'https://avatars.githubusercontent.com/u/23313167?v=4',
28+
// 或者
29+
logo: {
30+
src: 'https://avatars.githubusercontent.com/u/23313167?v=4',
31+
alt: 'logo',
32+
},
33+
// 或者
34+
logo: {
35+
light: 'https://avatars.githubusercontent.com/u/23313167?v=4',
36+
dark: 'https://avatars.githubusercontent.com/u/23313167?v=4',
37+
alt: 'logo',
38+
},
39+
```
40+
41+
### cover
42+
43+
- Type: `string` | `object`
44+
45+
网站的封面图片,使用方式同 logo
46+
47+
### nav
48+
49+
- Type: `array`
50+
51+
网站的导航栏,和 vitepress 具有相同的配置
52+
53+
```ts
54+
nav: [
55+
{ text: 'Home', link: '/' },
56+
{ text: 'Tag', link: '/tag' },
57+
{ text: 'Category', link: '/category' },
58+
],
59+
```
60+
61+
### socialLinks
62+
63+
- Type: `array`
64+
65+
网站的社交链接,和 vitepress 具有相同的配置
66+
67+
```ts
68+
socialLinks: [
69+
{
70+
ariaLabel: 'GitHub',
71+
link: 'https://github.com/tolking/vitepress-theme-ououe',
72+
icon: 'github',
73+
},
74+
],
75+
```
76+
77+
### pagination
78+
79+
- Type: `object | array`
80+
81+
分页的配置,具体的使用方法请参考[分页](./pagination.md)
82+
83+
### excerpt
84+
85+
- Type: `string | boolean | function`
86+
- default: `---`
87+
88+
如何分割文章的摘要
89+
90+
```ts
91+
excerpt: '<!-- more -->',
92+
```
93+
94+
### tag
95+
96+
- Type: `string`
97+
98+
标签的链接地址。在使用前,你需要参考[标签和分类](./tag.md)来配置 tag 的页面
99+
100+
```ts
101+
tag: '/tag',
102+
```
103+
104+
### category
105+
106+
- Type: `string`
107+
108+
分类的链接地址。在使用前,你需要参考[标签和分类](./tag.md)来配置 category 的页面
109+
110+
```ts
111+
category: '/category',
112+
```
113+
114+
### createTime
115+
116+
- Type: `object`
117+
118+
如何显示创建时间
119+
120+
```ts
121+
createTime: {
122+
text: '创建时间',
123+
format: (date) => new Date(date).toLocaleDateString(),
124+
},
125+
```
126+
127+
### lastUpdated
128+
129+
- Type: `object`
130+
131+
如何显示最后更新时间
132+
133+
```ts
134+
lastUpdated: {
135+
text: '更新时间',
136+
format: (date) => new Date(date).toLocaleDateString(),
137+
},
138+
```
139+
140+
### readingProgress
141+
142+
- Type: `boolean | 'top' | 'bottom' | 'left' | 'right'`
143+
144+
如何显示阅读进度条,仅在文章页面有效
145+
146+
### footer
147+
148+
- Type: `object`
149+
150+
页脚的显示内容
151+
152+
```ts
153+
footer: {
154+
copyright: 'copyright © 2023',
155+
},
156+
```
157+
158+
### search
159+
160+
- Type: `object`
161+
162+
搜索的配置,具体的使用方法请参考[搜索](https://vitepress.dev/reference/default-theme-search)
163+
164+
```ts
165+
search: {
166+
provider: 'local',
167+
},
168+
```
169+
170+
:::details 类型声明
171+
<<< @./../src/types/theme.ts
172+
:::

docs/posts/frontmatter.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: frontmatter
3+
descript: 如何配置博客的 frontmatter
4+
date: 2023-08-19
5+
image: https://picsum.photos/536/354?random=4
6+
index: 4
7+
tags:
8+
- guide
9+
- frontmatter
10+
categories:
11+
- docs
12+
---
13+
14+
如何配置博客文章的 frontmatter 信息
15+
16+
<!-- more -->
17+
18+
## 使用
19+
20+
- 一个标准文章的 frontmatter
21+
22+
```md
23+
---
24+
title: 文章的标题
25+
descript: 文章的描述
26+
date: 2023-08-19
27+
image: 图片链接 (可以省略)
28+
tags:
29+
- guide
30+
- frontmatter
31+
categories:
32+
- docs
33+
---
34+
```
35+
36+
- 一些控制界面的参数
37+
38+
```md
39+
---
40+
createTime: false
41+
lastUpdated: false
42+
articlePagination: false
43+
footer: false
44+
readingProgress: false (`boolean | 'top' | 'bottom' | 'left' | 'right'`)
45+
---
46+
```
47+
48+
- 特殊的属性 layout
49+
50+
```md
51+
---
52+
layout: article (`'page' | 'tag' | 'category' | 'article'`)
53+
---
54+
```
55+
56+
参考 [标签和分类](./tag.md)[分页](./pagination.md) 使用

0 commit comments

Comments
 (0)