Skip to content

Commit 6fd83e1

Browse files
author
reco_luan
committed
perf(vuepress-theme-reco): optimize the home page and subSidebar
1 parent 7b4468b commit 6fd83e1

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export default {
164164
padding: 0;
165165
margin: 0px auto;
166166
.hero {
167+
margin $navbarHeight auto 0
167168
position relative
168169
box-sizing border-box
169170
padding 0 20px

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
<Comments v-if="recoShowModule" :isShowComments="shouldShowComments"/>
7373
</ModuleTransition>
7474

75-
<ModuleTransition delay="0.4">
76-
<SubSidebar class="side-bar" />
75+
<ModuleTransition delay="0.08">
76+
<SubSidebar v-if="recoShowModule" class="side-bar" />
7777
</ModuleTransition>
7878
</main>
7979
</template>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default {
102102
.tags
103103
.tag-item
104104
font-family Ubuntu, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif
105+
cursor pointer
105106
&.active
106107
color $accentColor
107108
&:hover

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export default {
5454
},
5555
5656
mounted () {
57-
this.activationLink()
58-
this.isInViewPortOfOne()
57+
// this.activationLink()
58+
// this.isInViewPortOfOne()
5959
},
6060
6161
updated: function () {

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ export default {
1010
},
1111
methods: {
1212
isLinkActive (header) {
13-
return isActive(this.$route, this.$page.path + '#' + header.slug)
13+
const active = isActive(this.$route, this.$page.path + '#' + header.slug)
14+
if (active) {
15+
setTimeout(() => {
16+
console.log(document.querySelector(`.${header.slug}`))
17+
document.querySelector(`.${header.slug}`).scrollIntoView()
18+
}, 300)
19+
}
20+
return active
1421
}
1522
},
1623
render (h) {
@@ -27,7 +34,7 @@ export default {
2734
attr: { key: header.title }
2835
}, [
2936
h('router-link', {
30-
class: { 'sidebar-link': true },
37+
class: { 'sidebar-link': true, [`${header.slug}`]: true },
3138
props: { to: `${this.$page.path}#${header.slug}` }
3239
}, header.title)
3340
])

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

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,30 @@ h1, h2, h3, h4, h5, h6
111111
font-weight 500
112112
line-height 1.25
113113
.content__default:not(.custom) > &
114-
margin-top 1.2rem
115-
margin-bottom 1rem
114+
margin-top (0.5rem - $navbarHeight)
115+
padding-top ($navbarHeight + 1rem)
116+
margin-bottom 0
117+
&:first-child
118+
margin-top -3.5rem
119+
margin-bottom 1rem
120+
+ p, + pre, + .custom-block
121+
margin-top 2rem
116122

117123
h1
118124
font-size 1.6rem
119125

120126
h2
127+
position relative
121128
padding-left 0.8rem
122129
font-size 1.4rem
123-
border-left 5px solid $accentColor
130+
&::before
131+
position: absolute
132+
left 0
133+
bottom 0
134+
display: block
135+
height 1.8rem
136+
content: ''
137+
border-left 5px solid $accentColor
124138

125139
h3
126140
font-size 1.2rem

0 commit comments

Comments
 (0)