feat(toc): support fontawesome and ruby in TOC

This commit is contained in:
Dillon 2020-02-22 00:34:44 +08:00
parent 4e6fe224cc
commit c8fee1783a
8 changed files with 58 additions and 39 deletions

View file

@ -131,3 +131,21 @@
} }
} }
} }
.toc {
ruby {
background: $code-background-color;
rt {
color: $global-font-secondary-color;
}
.dark-theme & {
background: $code-background-color-dark;
rt {
color: $global-font-secondary-color-dark;
}
}
}
}

View file

@ -9,6 +9,16 @@ theme = "LoveIt"
# 主题目录 # 主题目录
themesDir = "../.." themesDir = "../.."
# whether to use robots.txt
# 是否使用 robots.txt
enableRobotsTXT = true
# whether to use git commit log to generate lastmod record
# 是否使用 git 信息来生成文章的上次修改时间
enableGitInfo = false
# whether to use emoji code
# 是否使用 emoji 代码
enableEmoji = true
[languages] [languages]
[languages.en] [languages.en]
weight = 1 weight = 1
@ -16,16 +26,10 @@ themesDir = "../.."
languageCode = "en" languageCode = "en"
# website title # website title
title = "LoveIt Theme" title = "LoveIt Theme"
# whether to use git commit log to generate lastmod record
enableGitInfo = false
# whether to include chinese/japanese/korean # whether to include chinese/japanese/korean
hasCJKLanguage = false hasCJKLanguage = false
# default amount of posts in each pages # default amount of posts in each pages
paginate = 12 paginate = 12
# whether to use emoji code
enableEmoji = true
# whether to use robots.txt
enableRobotsTXT = true
# [UA-XXXXXXXX-X] google analytics code # [UA-XXXXXXXX-X] google analytics code
googleAnalytics = "" googleAnalytics = ""
# copyright description used only for seo schema # copyright description used only for seo schema
@ -311,16 +315,10 @@ themesDir = "../.."
languageCode = "zh" languageCode = "zh"
# 网站标题 # 网站标题
title = "LoveIt 主题" title = "LoveIt 主题"
# 是否使用 git 信息来生成文章的上次修改时间
enableGitInfo = false
# 是否包括中日韩文字 # 是否包括中日韩文字
hasCJKLanguage = true hasCJKLanguage = true
# 默认每页列表显示的文章数目 # 默认每页列表显示的文章数目
paginate = 12 paginate = 12
# 是否使用 emoji 代码
enableEmoji = true
# 是否使用 robots.txt
enableRobotsTXT = true
# [UA-XXXXXXXX-X] 谷歌分析代号 # [UA-XXXXXXXX-X] 谷歌分析代号
googleAnalytics = "" googleAnalytics = ""
# 版权描述,仅仅用于 SEO # 版权描述,仅仅用于 SEO

View file

@ -0,0 +1,9 @@
{{- /* Checkbox unchecked */ -}}
{{- $REin := `<input disabled="" type="checkbox">` -}}
{{- $REout := `<i class="far fa-check-square fa-fw"></i>` -}}
{{- $content := replaceRE $REin $REout . -}}
{{- /* Checkbox checked */ -}}
{{- $REin = `<input checked="" disabled="" type="checkbox">` -}}
{{- $REout = `<i class="far fa-square fa-fw"></i>` -}}
{{- return replaceRE $REin $REout $content -}}

View file

@ -0,0 +1,5 @@
{{- /* Font Awesome */ -}}
{{- /* :(far fa-circle): -> <i class="far fa-circle fa-fw"></i> */ -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- return replaceRE $REin $REout . -}}

View file

@ -0,0 +1,5 @@
{{- /* Ruby */ -}}
{{- /* [EN]^(English) -> <strong><ruby>EN<rt>English</rt></ruby></strong> */ -}}
{{- $REin := `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout := `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- return replaceRE $REin $REout . -}}

View file

@ -1,28 +1,9 @@
{{- /* Font Awesome */ -}} {{- $content := . -}}
{{- /* :(far fa-circle): -> <i class="far fa-circle fa-fw"></i> */ -}}
{{- $REin := `:\(([\w- ]+?)\):` -}}
{{- $REout := `<i class="$1 fa-fw"></i>` -}}
{{- $content := replaceRE $REin $REout . -}}
{{- /* Ruby */ -}} {{- $content = partial "function/fontawesome.html" $content -}}
{{- /* [EN]^(English) -> <strong><ruby>EN<rt>English</rt></ruby></strong> */ -}}
{{- $REin = `\[(.+?)\]\^\((.+?)\)` -}}
{{- $REout = `<strong><ruby>$1<rt>$2</rt></ruby></strong>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Checkbox */ -}} {{- $content = partial "function/ruby.html" $content -}}
{{- $REin = `<input disabled="" type="checkbox">` -}}
{{- $REout = `<i class="far fa-check-square fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Checkbox checked */ -}} {{- $content = partial "function/checkbox.html" $content -}}
{{- $REin = `<input checked="" disabled="" type="checkbox">` -}}
{{- $REout = `<i class="far fa-square fa-fw"></i>` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- /* Fix <sup>[return]</sup> */ -}}
{{- $REin = `<sup>\[return\]</sup>` -}}
{{- $REout = `↩︎` -}}
{{- $content = replaceRE $REin $REout $content -}}
{{- $content | safeHTML -}} {{- $content | safeHTML -}}

View file

@ -52,12 +52,12 @@
{{- /* TOC */ -}} {{- /* TOC */ -}}
{{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}} {{- if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) -}}
<div class="toc-auto" id="toc-auto"> <div class="toc" id="toc-auto">
<h2 class="toc-title">{{ T "toc" }}</h2> <h2 class="toc-title">{{ T "toc" }}</h2>
{{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }} {{- $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default true }}
<div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div> <div class="toc-content{{ if not (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false)) }} always-active{{ end }}" id="toc-content-auto"></div>
</div> </div>
<div class="toc-static" id="toc-static"> <div class="toc" id="toc-static">
<details> <details>
<summary> <summary>
<div class="toc-title"> <div class="toc-title">
@ -66,7 +66,10 @@
</div> </div>
</summary> </summary>
<div class="toc-content" id="toc-content-static"> <div class="toc-content" id="toc-content-static">
{{- partial "single/content.html" .TableOfContents -}} {{- $toc := .TableOfContents -}}
{{- $toc = partial "function/fontawesome.html" $toc -}}
{{- $toc = partial "function/ruby.html" $toc -}}
{{- $toc | safeHTML -}}
</div> </div>
</details> </details>
</div> </div>