feat: 適配 hexo 5.0.0 的 prismjs, 代碼主題和各項功能

refactor: 移除 代碼default主題
fix: 修復夜間模式下代碼塊有背景的bugs(沒開啟渲染的情況下)
feat: 增加 code font-size配置 close #322
refactor: 更改配置中 code-font 為 code-font-family
feat: Pjax下,刷新頁面時,會滾動到上次瀏覽的位置
fix: 修復mathjax溢出屏幕的Bugs close #321
This commit is contained in:
Jerry
2020-08-19 00:21:18 +08:00
parent 973306898a
commit 543cd94c9f
15 changed files with 557 additions and 183 deletions

View File

@@ -1,12 +1,16 @@
// https://github.com/equinusocio/vsc-material-theme
$highlight_theme = hexo-config('highlight_theme')
$highlighEnable = hexo-config('rootConfig.highlight') && hexo-config('rootConfig.highlight.enable')
$prismjsEnable = hexo-config('rootConfig.prismjs') && hexo-config('rootConfig.prismjs.enable')
wordWrap = !hexo-config('rootConfig.highlight.line_number') && hexo-config('code_word_wrap')
@require 'theme'
if $highlight_theme != false
@require 'diff'
if $highlighEnable
@require 'highlight/index'
wordWrap = !hexo-config('rootConfig.highlight.line_number') && hexo-config('code_word_wrap')
if $prismjsEnable
@require 'prismjs/index'
$code-block
overflow: auto
@@ -45,7 +49,7 @@ blockquote
#article-container
pre,
code
font-family: $code-font !important
font-family: $code-font-family !important
code
padding: .1rem .2rem
@@ -58,6 +62,7 @@ blockquote
pre
@extend $code-block
padding: 10px 20px
font-size: $code-font-size
code
padding: 0
@@ -74,101 +79,52 @@ blockquote
padding: 8px 0
border: none
.line
if wordWrap
&:before
display: inline-block
padding: 0 .3rem 0 0
min-width: 1.6rem
color: $highlight-gutter.color
content: counter(line)
counter-increment: line
text-align: left
.highlight-tools
position: relative
display: flex
align-items: center
overflow: hidden
min-height: 1.2rem
height: 2.15em
background: $highlight-tools.bg-color
color: $highlight-tools.color
&.marked
background-color: $highlight-selection
&.closed + table
display: none
table
display: block
overflow: auto
border: none
.expand
position: absolute
padding: .4rem .7rem
cursor: pointer
transition: transform .3s
td
padding: 0
border: none
& + .code-lang
left: 1.7rem
figcaption
clearfix()
padding: .3rem 0 .1rem .7rem
font-size: 1em
line-height: 1em
&.closed
transition: all .3s
transform: rotate(-90deg) !important
a
float: right
padding-right: 10px
color: $highlight-foreground
.code-lang
position: absolute
left: .7rem
text-transform: capitalize
font-weight: bold
font-size: 1.15em
&:hover
border-bottom-color: $highlight-foreground
.copy-notice
position: absolute
right: 1.7rem
opacity: 0
.gutter pre
padding-right: .5rem
padding-left: .5rem
background-color: $highlight-gutter.bg-color
color: $highlight-gutter.color
text-align: right
.copy-button
position: absolute
right: .7rem
cursor: pointer
transition: color .2s
.code pre
padding-right: .5rem
padding-left: .5rem
width: 100%
.highlight-tools
position: relative
display: flex
align-items: center
overflow: hidden
min-height: 1.2rem
height: 2.15em
background: $highlight-tools.bg-color
color: $highlight-tools.color
&.closed + table
display: none
.expand
position: absolute
padding: .4rem .7rem
cursor: pointer
transition: transform .3s
& + .code-lang
left: 1.7rem
&.closed
transition: all .3s
transform: rotate(-90deg) !important
.code-lang
position: absolute
left: .7rem
text-transform: capitalize
font-weight: bold
font-size: 1.15em
.copy-notice
position: absolute
right: 1.7rem
opacity: 0
.copy-button
position: absolute
right: .7rem
cursor: pointer
transition: color .2s
&:hover
color: $theme-color
&:hover
color: $theme-color
.gutter
user-select: none