diff options
author | Dillon <dillonzq@outlook.com> | 2020-02-21 19:34:44 +0300 |
---|---|---|
committer | Dillon <dillonzq@outlook.com> | 2020-02-21 19:34:44 +0300 |
commit | c8fee1783a27c17454b8e7a6b08eb5de099a4dc4 (patch) | |
tree | dbd9abce1db835dee38dd85c208abd8f2d2407a0 /layouts | |
parent | 4e6fe224cc1934aa0459b2d888f243463bb998f7 (diff) |
feat(toc): support fontawesome and ruby in TOC
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/function/checkbox.html | 9 | ||||
-rw-r--r-- | layouts/partials/function/fontawesome.html | 5 | ||||
-rw-r--r-- | layouts/partials/function/ruby.html | 5 | ||||
-rw-r--r-- | layouts/partials/single/content.html | 27 | ||||
-rw-r--r-- | layouts/posts/single.html | 9 |
5 files changed, 29 insertions, 26 deletions
diff --git a/layouts/partials/function/checkbox.html b/layouts/partials/function/checkbox.html new file mode 100644 index 0000000..820c4e0 --- /dev/null +++ b/layouts/partials/function/checkbox.html @@ -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 -}} diff --git a/layouts/partials/function/fontawesome.html b/layouts/partials/function/fontawesome.html new file mode 100644 index 0000000..270aab5 --- /dev/null +++ b/layouts/partials/function/fontawesome.html @@ -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 . -}} diff --git a/layouts/partials/function/ruby.html b/layouts/partials/function/ruby.html new file mode 100644 index 0000000..49aa35b --- /dev/null +++ b/layouts/partials/function/ruby.html @@ -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 . -}} diff --git a/layouts/partials/single/content.html b/layouts/partials/single/content.html index 67130f1..c0327ca 100644 --- a/layouts/partials/single/content.html +++ b/layouts/partials/single/content.html @@ -1,28 +1,9 @@ -{{- /* Font Awesome */ -}} -{{- /* :(far fa-circle): -> <i class="far fa-circle fa-fw"></i> */ -}} -{{- $REin := `:\(([\w- ]+?)\):` -}} -{{- $REout := `<i class="$1 fa-fw"></i>` -}} -{{- $content := replaceRE $REin $REout . -}} +{{- $content := . -}} -{{- /* Ruby */ -}} -{{- /* [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 -}} +{{- $content = partial "function/fontawesome.html" $content -}} -{{- /* Checkbox */ -}} -{{- $REin = `<input disabled="" type="checkbox">` -}} -{{- $REout = `<i class="far fa-check-square fa-fw"></i>` -}} -{{- $content = replaceRE $REin $REout $content -}} +{{- $content = partial "function/ruby.html" $content -}} -{{- /* Checkbox checked */ -}} -{{- $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 = partial "function/checkbox.html" $content -}} {{- $content | safeHTML -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 3abd031..bacdb8b 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -52,12 +52,12 @@ {{- /* TOC */ -}} {{- 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> {{- $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> - <div class="toc-static" id="toc-static"> + <div class="toc" id="toc-static"> <details> <summary> <div class="toc-title"> @@ -66,7 +66,10 @@ </div> </summary> <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> </details> </div> |