Skip to content

Commit f3476f3

Browse files
author
reco_luan
committed
Merge branch 'develop' of github.com:vuepress-reco/vuepress-theme-reco into develop
2 parents c9f251d + 4312914 commit f3476f3

File tree

11 files changed

+52
-110
lines changed

11 files changed

+52
-110
lines changed

example/.vuepress/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
search: true,
5959
searchMaxSuggestions: 10,
6060
// 自动形成侧边导航
61-
// sidebar: 'auto',
61+
subSidebar: 'auto',
6262
sidebarDepth: 4,
6363
// 最后更新时间
6464
lastUpdated: 'Last Updated',

example/views/sidebargroup/bar1.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
---
2-
title: bar1
3-
---
1+
# bar test
42

53
bar1

example/views/sidebargroup/bar2.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ title: bar2
44

55
bar2
66

7+
## sidebar
8+
79
## 二级标题1
810

911
### 三级标题1-1
1012

13+
14+
1115
#### 四级标题1-1-1
1216
#### 四级标题1-1-2
1317
#### 四级标题1-1-3

packages/vuepress-theme-reco/components/Home.vue

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -134,59 +134,6 @@ export default {
134134
transform scale(1.05)
135135
}
136136
}
137-
138-
// &.reco-hide {
139-
// .hero {
140-
// img {
141-
// load-start()
142-
// }
143-
// .h1 {
144-
// load-start()
145-
// }
146-
// .description {
147-
// load-start()
148-
// }
149-
// .huawei {
150-
// load-start()
151-
// }
152-
// .action-button {
153-
// load-start()
154-
// }
155-
// }
156-
// .features {
157-
// load-start()
158-
// }
159-
// .home-center {
160-
// load-start()
161-
// padding 0
162-
// }
163-
// }
164-
165-
// &.reco-show {
166-
// .hero {
167-
// img {
168-
// load-end(0.08s)
169-
// }
170-
// .h1 {
171-
// load-end(0.16s)
172-
// }
173-
// .description {
174-
// load-end(0.24s)
175-
// }
176-
// .huawei {
177-
// load-end(0.32s)
178-
// }
179-
// .action-button {
180-
// load-end(0.4s)
181-
// }
182-
// }
183-
// .features {
184-
// load-end(0.40s)
185-
// }
186-
// .home-center {
187-
// load-end(0.48s)
188-
// }
189-
// }
190137
}
191138
192139
@media (max-width: $MQMobile) {

packages/vuepress-theme-reco/components/Page.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<main class="page" :style="pageStyle">
33
<ModuleTransition>
44
<div v-show="recoShowModule && $page.title" class="page-title">
5-
<h1>{{$page.title}}</h1>
5+
<h1 class="title">{{$page.title}}</h1>
66
<PageInfo :pageInfo="$page" :showAccessNumber="showAccessNumber"></PageInfo>
77
</div>
88
</ModuleTransition>
@@ -171,11 +171,14 @@ export default {
171171
)
172172
},
173173
pageStyle () {
174-
const headers = this.$page.headers || []
175-
return headers.length > 0 ? {} : { paddingRight: '0' }
174+
return this.$showSubSideBar ? {} : { paddingRight: '0' }
176175
}
177176
},
178177
178+
created () {
179+
console.log(this)
180+
},
181+
179182
methods: {
180183
createEditLink (repo, docsRepo, docsDir, docsBranch, path) {
181184
const bitbucket = /bitbucket.org/

packages/vuepress-theme-reco/components/SubSidebar.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import { isActive } from '@theme/helpers/utils'
44
export default {
55
computed: {
66
headers () {
7-
const headers = (this.$page.headers || []).filter(header => header.level === 2)
8-
return headers
7+
return this.$showSubSideBar ? this.$page.headers : []
98
}
109
},
1110
methods: {
1211
isLinkActive (header) {
1312
const active = isActive(this.$route, this.$page.path + '#' + header.slug)
1413
if (active) {
1514
setTimeout(() => {
16-
console.log(document.querySelector(`.${header.slug}`))
17-
document.querySelector(`.${header.slug}`).scrollIntoView()
15+
document.querySelector(`.reco-${header.slug}`).scrollIntoView()
1816
}, 300)
1917
}
2018
return active
@@ -23,9 +21,9 @@ export default {
2321
render (h) {
2422
return h('ul', {
2523
class: { 'sub-sidebar-wrapper': true },
26-
style: { width: (this.$page.headers || []).length > 0 ? '12rem' : '0' }
24+
style: { width: this.headers.length > 0 ? '12rem' : '0' }
2725
}, [
28-
...(this.$page.headers || []).map(header => {
26+
...this.headers.map(header => {
2927
return h('li', {
3028
class: {
3129
active: this.isLinkActive(header),
@@ -34,7 +32,7 @@ export default {
3432
attr: { key: header.title }
3533
}, [
3634
h('router-link', {
37-
class: { 'sidebar-link': true, [`${header.slug}`]: true },
35+
class: { 'sidebar-link': true, [`reco-${header.slug}`]: true },
3836
props: { to: `${this.$page.path}#${header.slug}` }
3937
}, header.title)
4038
])

packages/vuepress-theme-reco/mixins/index.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

packages/vuepress-theme-reco/mixins/locales.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ import { zhHans, zhHant, en, ja, ko } from '../locales/index'
33
export default {
44
computed: {
55
$recoLocales () {
6-
const recoLocales = this.$themeLocaleConfig.recoLocales
7-
if (recoLocales && recoLocales.homeBlog) {
8-
return { homeBlog: recoLocales.homeBlog }
9-
}
6+
const recoLocales = this.$themeLocaleConfig.recoLocales || {}
7+
108
if (/^zh\-(CN|SG)$/.test(this.$lang)) {
11-
return zhHans
9+
return { ...zhHans, ...recoLocales }
1210
}
1311
if (/^zh\-(HK|MO|TW)$/.test(this.$lang)) {
14-
return zhHant
12+
return { ...zhHant, ...recoLocales }
1513
}
1614
if (/^ja\-JP$/.test(this.$lang)) {
17-
return ja
15+
return { ...ja, ...recoLocales }
1816
}
1917
if (/^ko\-KR$/.test(this.$lang)) {
20-
return ko
18+
return { ...ko, ...recoLocales }
2119
}
22-
return en
20+
return { ...en, ...recoLocales }
2321
}
2422
}
2523
}

packages/vuepress-theme-reco/mixins/posts.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ export default {
4141
}
4242

4343
return formatPagesArr
44+
},
45+
$showSubSideBar () {
46+
const {
47+
$themeConfig: { subSidebar: themeSidebar },
48+
$frontmatter: { subSidebar: pageSidebar }
49+
} = this
50+
const headers = this.$page.headers || []
51+
52+
if ((themeSidebar === 'auto' || pageSidebar === 'auto') && headers.length > 0) {
53+
return true
54+
}
55+
return false
4456
}
4557
}
4658
}

packages/vuepress-theme-reco/styles/theme.styl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ body
6464
border-radius 4px
6565
img
6666
max-width 100%
67+
*:first-child
68+
margin-top 0
6769

6870
.content__default.custom
6971
padding 0
@@ -111,17 +113,17 @@ h1, h2, h3, h4, h5, h6
111113
font-weight 500
112114
line-height 1.25
113115
.content__default:not(.custom) > &
114-
margin-top (0.5rem - $navbarHeight)
115-
padding-top ($navbarHeight + 1rem)
116+
margin-top (2.1rem - $navbarHeight)
117+
padding-top $navbarHeight
116118
margin-bottom 0
117119
&:first-child
118120
margin-top -3.5rem
119-
margin-bottom 1rem
120-
+ p, + pre, + .custom-block
121-
margin-top 2rem
122121

123122
h1
123+
display none
124124
font-size 1.6rem
125+
&.title
126+
display block
125127

126128
h2
127129
position relative
@@ -195,7 +197,7 @@ th, td
195197
@require 'mobile.styl'
196198

197199
.iconfont
198-
font-size: 0.9rem;
200+
font-size: 12px;
199201
color: var(--text-color-sub);
200202

201203
/************** 滚动条 **************/

0 commit comments

Comments
 (0)