Skip to content

Commit 198ac24

Browse files
author
reco_luan
committed
feat: multi-language(part.3)
1 parent 6795270 commit 198ac24

File tree

8 files changed

+172
-2
lines changed

8 files changed

+172
-2
lines changed

example/docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ module.exports = {
3636
text: 'Tag' // 默认 “标签”
3737
}
3838
},
39+
type: 'blog',
3940
logo: '/head.png',
4041
authorAvatar: '/head.png',
4142
// 搜索设置

example/docs/en/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
home: true
3+
# heroImage: /hero.png
4+
# heroImageStyle: {
5+
# maxWidth: '600px',
6+
# width: '100%',
7+
# display: block,
8+
# margin: '9rem auto 2rem',
9+
# background: '#fff',
10+
# borderRadius: '1rem',
11+
# }
12+
# isShowTitleInHome: false
13+
actionText: Guide
14+
actionLink: /views/other/guide
15+
features:
16+
- title: Yesterday
17+
details: 开发一款看着开心、写着顺手的 vuepress 博客主题
18+
- title: Today
19+
details: 希望帮助更多的人花更多的时间在内容创作上,而不是博客搭建上
20+
- title: Tomorrow
21+
details: 希望更多的爱好者能够参与进来,帮助这个主题更好的成长
22+
---
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: first page in category1
3+
date: 2018-12-15
4+
tags:
5+
- tag1
6+
categories:
7+
- category1
8+
---
9+
10+
first page in category1
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: second page in category1
3+
date: 2019-09-21
4+
tags:
5+
- tag2
6+
categories:
7+
- category1
8+
---
9+
10+
second page in category1
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: vuepress-theme-reco
3+
date: 2019-04-09
4+
categories:
5+
- other
6+
- test
7+
---
8+
9+
![vuepress](https://img.shields.io/badge/vuepress-0.14.8-brightgreen.svg)
10+
![leancloud-storage](https://img.shields.io/badge/leancloud--storage-3.10.1-orange.svg)
11+
![valine](https://img.shields.io/badge/valine-1.3.4-blue.svg)
12+
13+
|a|b|
14+
|-|-|
15+
|这是一个vuepress主题,旨在添加博客所需的分类、TAB墙、分页、评论等能;a|b这是一个vuepress主题,旨在添加博客所需的分类、TAB墙、分页、评论等能;|
16+
|a|b|
17+
|a|b|
18+
|a|b|
19+
20+
::: tip 介绍
21+
1. 这是一个vuepress主题,旨在添加博客所需的分类、TAB墙、分页、评论等能;<br>
22+
2. 主题追求极简,根据 vuepress 的默认主题修改而成,官方的主题配置仍然适用;<br>
23+
3. 你可以打开 [午后南杂](http://recoluan.gitlab.io) 来查看效果。
24+
:::
25+
26+
::: warning 介绍
27+
1. 这是一个vuepress主题,旨在添加博客所需的分类、TAB墙、分页、评论等能;<br>
28+
2. 主题追求极简,根据 vuepress 的默认主题修改而成,官方的主题配置仍然适用;<br>
29+
3. 你可以打开 [午后南杂](http://recoluan.gitlab.io) 来查看效果。
30+
:::
31+
32+
::: danger 介绍
33+
1. 这是一个vuepress主题,旨在添加博客所需的分类、TAB墙、分页、评论等能;<br>
34+
2. 主题追求极简,根据 vuepress 的默认主题修改而成,官方的主题配置仍然适用;<br>
35+
3. 你可以打开 [午后南杂](http://recoluan.gitlab.io) 来查看效果。
36+
:::
37+
38+
::: theorem 牛顿第一定律
39+
假若施加于某物体的外力为零,则该物体的运动速度不变。
40+
41+
::: right
42+
来自 [维基百科](https://zh.wikipedia.org/wiki/%E7%89%9B%E9%A1%BF%E8%BF%90%E5%8A%A8%E5%AE%9A%E5%BE%8B)
43+
:::
44+
45+
::: details
46+
这是一个详情块,在 IE / Edge 中不生效
47+
:::
48+
49+
> 测试
50+
51+
## Use
52+
53+
**Build**
54+
55+
```bash
56+
npm run build
57+
58+
# or
59+
60+
yarn build
61+
```
62+
63+
**Server**
64+
65+
```bash
66+
npm run dev
67+
68+
# or
69+
70+
yarn dev
71+
```
72+
73+
## Play Together
74+
75+
### 0.x
76+
77+
`vuepress-theme-reco@0.x` 是基于 `vuepress@0.x` 的博客主题。
78+
79+
`vuepress@0.x` 功能比较简单,只适合书写简单的文档,但好在支持主题自定义,而个人又希望能够用它来书写博客,原因就是它足够的简洁,毫无疑问,这也符合很多程序员的观念,也就是在这种情况下,`vuepress-theme-reco@0.x` 的第一个版本经过一个通宵而产生。
80+
81+
主题开源不久,很多朋友通过各种联系方式,给到很多好的意见和建议,所以我个人也在积极地更新。
82+
83+
因为我是一名前端开发工程师,开发的过程中,总是想着能不能加入一些炫酷的效果,有很多次都是添加上又去掉,反反复复,最后都是被 **简洁** 的这个原则阻止掉,毕竟,现在我是将它当作一个产品来看待,并不是一个技术或者是技巧的尝试项目。
84+
85+
### 1.x
86+
87+
随着不断有用户过来询问:为什么 `vuepress-theme-reco@0.x` 不能在 `vuepress@1.x` 上使用?本来只是打算对 `vuepress-theme-reco@0.x` 进行简单的bug修复的我,终究还是忍不住,开始了 `vuepress-theme-reco@1.x` 的开发。又是在一个寂静的凌晨两点半(晚上就是出活快),我默默地开始了。
88+
89+
主题升级的关键也就是 `@vuepress/plugin-blog` 这款官方插件,它不需要再去麻烦地过滤数据,将分类和标签的相关信息直接存在 `$categories``$tags` 这两个全局变量中。借助于 `@vuepress/plugin-blog`,分类和标签功能更容易实现,但也有了一些局限。接下来两三天的时间,都是在进行功能的迁移和一些bug的修复。
90+
91+
`vuepress-theme-reco@0.x` 的开发中,更加深刻地明白了模块化和组件化编程的重要性,如果当初没有把一些功能进行封装,而是直接简单的复制,这次升级也不会这么顺利。模块拆分的越细,使用就会越灵活。
92+
93+
### CLI
94+
95+
还是衷心地希望能有更多的朋友参与进来,更快地去完善它。接下来时间允许的情况下,我会开源一款自动生成博客的脚手架,略过配置步骤,直接书写优质内容,这也是我后来逐渐形成的一种信念,就是希望能让这款主题,功能越完善,使用越来越简单。
96+
97+
## License
98+
[MIT](https://github.com/recoluan/vuepress-theme-reco/blob/master/LICENSE)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Installation and reference
3+
date: 2019-04-09 11:11:11
4+
categories:
5+
- other
6+
---
7+
8+
## Install
9+
10+
```bash
11+
npm install vuepress-theme-reco -dev--save
12+
13+
# or
14+
15+
yarn add vuepress-theme-reco
16+
```
17+
18+
## Usage
19+
20+
```javascript
21+
// .vuepress/config.js
22+
23+
module.exports = {
24+
theme: 'reco'
25+
}
26+
```

helpers/postData.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import { compareDate } from '@theme/helpers/utils'
22

33
// 过滤博客数据
44
export function filterPosts (posts, isTimeline, $lang) {
5+
// 存在问题,当前函数被调用两次,第一次获取不到实例this,所以找不到 $lang,所以对这种情况做一下处理
6+
if ($lang === undefined) return posts
57
posts = posts.filter((item, index) => {
68
const { title, frontmatter: { home, date, publish, lang }} = item
79
// 过滤多个分类时产生的重复数据
810
if (posts.indexOf(item) !== index) {
911
return false
1012
} else {
1113
const someConditions = home == true || title == undefined || publish === false || (lang !== undefined && lang !== $lang)
12-
return isTimeline === true
14+
const boo = isTimeline === true
1315
? !(someConditions || date === undefined)
1416
: !someConditions
17+
return boo
1518
}
1619
})
1720
return posts

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuepress-theme-reco",
3-
"version": "1.3.2",
3+
"version": "1.3.3-alpha.1",
44
"description": "A simple and beautiful vuepress Blog & Doc theme.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)