Skip to content

feat: add docs #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: deploy

on:
workflow_dispatch:
push:
tags:
- 'v**'

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
registry-url: https://registry.npmjs.org/

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Install dependencies
run: pnpm i --frozen-lockfile

- name: Build
run: pnpm run build:docs

- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.PAGE }}
branch: gh-pages
folder: dist
clean: true
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

> A blog theme based on vitepress

Live Demo: [My Blog](https://ououe.com)
[Documentation](https://tolking.github.io/vitepress-theme-ououe)

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

## Install

Expand Down Expand Up @@ -33,7 +33,3 @@ export default defineConfigWithTheme<Theme>({
},
})
```

## Config

[Refer to type file](./src/types/theme.ts)
37 changes: 28 additions & 9 deletions examples/.vitepress/config.ts → docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,31 @@ import { defineConfigWithTheme } from 'vitepress'
import type { Theme } from '../../src/types'

export default defineConfigWithTheme<Theme>({
title: 'My Site',
description: 'This is my site',
// srcDir: 'posts',
// base: '/base/',
title: 'vitepress-theme-ououe',
description: 'A blog theme based on vitepress',
outDir: '../dist',
cleanUrls: true,
lastUpdated: true,

lang: 'zn-CN',
head: [
['link', { rel: 'icon', href: '/favicon.ico' }],
['meta', { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge,chrome=1' }],
['meta', { name: 'renderer', content: 'webkit' }],
['meta', { name: 'force-rendering', content: 'webkit' }],
['meta', { name: 'applicable-device', content: 'pc,mobile' }],
['meta', { name: 'author', content: 'tolking <[email protected]>' }],
],
// locales: {
// root: {
// label: 'English',
// lang: 'en'
// },
// zh: {
// label: '简体中文',
// lang: 'zh-CN',
// description: '为 vuepress 制作的一款主题'
// }
// },
themeConfig: {
// logo: {
// src: 'https://avatars.githubusercontent.com/u/23313167?v=4',
Expand All @@ -34,12 +52,13 @@ export default defineConfigWithTheme<Theme>({
},
],
pagination: {
// prev: "<-",
// next: "->",
prev: '<-',
next: '->',
// match: (path) => /^\/($|index|page-)/.test(path),
sort: (a, b) => a.index - b.index,
// filter: (page) => page.home,
},
// excerpt: '<!-- more -->',
excerpt: '<!-- more -->',
createTime: {
text: 'Create Time',
format: (date) => new Date(date).toLocaleDateString(),
Expand All @@ -54,7 +73,7 @@ export default defineConfigWithTheme<Theme>({
// { text: "Home", link: "/" },
// { text: "GitHub", link: "https://github.com/tolking/vitepress-theme-ououe" },
// ],
copyright: 'copyright © 2023',
copyright: 'tolking © 2023',
},
search: {
provider: 'local',
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/[page].paths.ts → docs/[page].paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
paths() {
const limit = 12 // Item count of each page
const files = fs
.readdirSync('examples/posts')
.readdirSync('docs/posts')
.filter((file) => !/^\[[^]*]\]\./.test(file))
const total = Math.ceil(files.length / limit)

Expand Down
File renamed without changes.
172 changes: 172 additions & 0 deletions docs/posts/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
---
title: 主题配置
descript: 如何配置博客的分页
date: 2023-08-19
image: https://picsum.photos/536/354?random=10
index: 10
tags:
- reference
- config
categories:
- docs
---

主题的所有配置项

<!-- more -->

## Options

### logo

- Type: `string` | `object`

网站的 logo 图片

```ts
logo: 'https://avatars.githubusercontent.com/u/23313167?v=4',
// 或者
logo: {
src: 'https://avatars.githubusercontent.com/u/23313167?v=4',
alt: 'logo',
},
// 或者
logo: {
light: 'https://avatars.githubusercontent.com/u/23313167?v=4',
dark: 'https://avatars.githubusercontent.com/u/23313167?v=4',
alt: 'logo',
},
```

### cover

- Type: `string` | `object`

网站的封面图片,使用方式同 logo

### nav

- Type: `array`

网站的导航栏,和 vitepress 具有相同的配置

```ts
nav: [
{ text: 'Home', link: '/' },
{ text: 'Tag', link: '/tag' },
{ text: 'Category', link: '/category' },
],
```

### socialLinks

- Type: `array`

网站的社交链接,和 vitepress 具有相同的配置

```ts
socialLinks: [
{
ariaLabel: 'GitHub',
link: 'https://github.com/tolking/vitepress-theme-ououe',
icon: 'github',
},
],
```

### pagination

- Type: `object | array`

分页的配置,具体的使用方法请参考[分页](./pagination.md)

### excerpt

- Type: `string | boolean | function`
- default: `---`

如何分割文章的摘要

```ts
excerpt: '<!-- more -->',
```

### tag

- Type: `string`

标签的链接地址。在使用前,你需要参考[标签和分类](./tag.md)来配置 tag 的页面

```ts
tag: '/tag',
```

### category

- Type: `string`

分类的链接地址。在使用前,你需要参考[标签和分类](./tag.md)来配置 category 的页面

```ts
category: '/category',
```

### createTime

- Type: `object`

如何显示创建时间

```ts
createTime: {
text: '创建时间',
format: (date) => new Date(date).toLocaleDateString(),
},
```

### lastUpdated

- Type: `object`

如何显示最后更新时间

```ts
lastUpdated: {
text: '更新时间',
format: (date) => new Date(date).toLocaleDateString(),
},
```

### readingProgress

- Type: `boolean | 'top' | 'bottom' | 'left' | 'right'`

如何显示阅读进度条,仅在文章页面有效

### footer

- Type: `object`

页脚的显示内容

```ts
footer: {
copyright: 'copyright © 2023',
},
```

### search

- Type: `object`

搜索的配置,具体的使用方法请参考[搜索](https://vitepress.dev/reference/default-theme-search)

```ts
search: {
provider: 'local',
},
```

:::details 类型声明
<<< @./../src/types/theme.ts
:::
56 changes: 56 additions & 0 deletions docs/posts/frontmatter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: frontmatter
descript: 如何配置博客的 frontmatter
date: 2023-08-19
image: https://picsum.photos/536/354?random=4
index: 4
tags:
- guide
- frontmatter
categories:
- docs
---

如何配置博客文章的 frontmatter 信息

<!-- more -->

## 使用

- 一个标准文章的 frontmatter

```md
---
title: 文章的标题
descript: 文章的描述
date: 2023-08-19
image: 图片链接 (可以省略)
tags:
- guide
- frontmatter
categories:
- docs
---
```

- 一些控制界面的参数

```md
---
createTime: false
lastUpdated: false
articlePagination: false
footer: false
readingProgress: false (`boolean | 'top' | 'bottom' | 'left' | 'right'`)
---
```

- 特殊的属性 layout

```md
---
layout: article (`'page' | 'tag' | 'category' | 'article'`)
---
```

参考 [标签和分类](./tag.md) 和 [分页](./pagination.md) 使用
Loading