Skip to content

Commit d425915

Browse files
author
reco_luan
committed
style(vuepress-theme-reco): optimize
1 parent a433a2b commit d425915

File tree

10 files changed

+26
-188
lines changed

10 files changed

+26
-188
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
yarn-error.log
33
.idea
4+
.DS_Store

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ a.sidebar-link
9292
display block!important
9393
color var(--text-color)
9494
padding 0.35rem 1rem 0.35rem 2.25rem
95-
line-height 1.4
95+
line-height 1.7
9696
background var(--background-color)
9797
// margin 0 0 0 1.5rem
9898
box-sizing: border-box
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import postMixin from '@theme/mixins/posts'
22
import localMixin from '@theme/mixins/locales'
3+
import { addLinkToHead } from '@theme/helpers/utils'
4+
import { registerCodeThemeCss } from '@theme/helpers/other'
35

46
export default ({
57
Vue,
@@ -9,16 +11,7 @@ export default ({
911
Vue.mixin(postMixin)
1012
Vue.mixin(localMixin)
1113
if (!isServer) {
12-
_registerCodeThemeCss(siteData.themeConfig.codeTheme)
14+
addLinkToHead('//at.alicdn.com/t/font_1030519_2ciwdtb4x65.css')
15+
registerCodeThemeCss(siteData.themeConfig.codeTheme)
1316
}
1417
}
15-
16-
function _registerCodeThemeCss (theme = 'tomorrow') {
17-
const themeArr = ['tomorrow', 'funky', 'okaidia', 'solarizedlight', 'default']
18-
19-
const link = document.createElement('link')
20-
link.rel = 'stylesheet'
21-
link.href = `//prismjs.com/themes/prism${themeArr.indexOf(theme) > -1 ? `-${theme}` : ''}.css`
22-
23-
document.head.append(link)
24-
}

packages/vuepress-theme-reco/helpers/other.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { addLinkToHead } from './utils'
12
export function getOneColor () {
23
const tagColorArr = [
34
'#e15b64',
@@ -16,3 +17,10 @@ export function getOneColor () {
1617
const index = Math.floor(Math.random() * tagColorArr.length)
1718
return tagColorArr[index]
1819
}
20+
21+
export function registerCodeThemeCss (theme = 'tomorrow') {
22+
const themeArr = ['tomorrow', 'funky', 'okaidia', 'solarizedlight', 'default']
23+
const href = `//prismjs.com/themes/prism${themeArr.indexOf(theme) > -1 ? `-${theme}` : ''}.css`
24+
25+
addLinkToHead(href)
26+
}

packages/vuepress-theme-reco/helpers/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ export function compareDate (a, b) {
243243
return getTimeNum(b) - getTimeNum(a)
244244
}
245245

246+
// 向 head 中添加 style
247+
export function addLinkToHead (href) {
248+
const iconLink = document.createElement('link')
249+
iconLink.rel = 'stylesheet'
250+
iconLink.href = href
251+
252+
document.head.append(iconLink)
253+
}
254+
246255
function ensureEndingSlash (path) {
247256
return /(\.html|\/)$/.test(path)
248257
? path
684 KB
Loading
127 KB
Loading

packages/vuepress-theme-reco/styles/iconfont.css

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ $maskColorDark ?= #000
4949
$homePageWidth = 1126px
5050
$contentWidth = 860px
5151
$sidebarWidth = 18rem
52+
$accentColor = #2c3e50

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@require './arrow'
55
@require './wrapper'
66
@require './toc'
7-
@require './iconfont.css'
7+
// @require './iconfont.css'
88

99
html, body
1010
padding 0
@@ -149,7 +149,7 @@ code, kbd, .line-number
149149
font-family source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace
150150

151151
p, ul, ol
152-
line-height 1.7
152+
line-height 2.2
153153

154154
hr
155155
border 0

0 commit comments

Comments
 (0)