feat(code): add support for code block folding (#259)

This commit is contained in:
Dillon
2020-04-26 03:25:10 +08:00
committed by GitHub
parent 41a92c6166
commit bcbc4268ea
32 changed files with 351 additions and 270 deletions

View File

@@ -1,12 +1,12 @@
{{- define "title" }}
{{- .Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
{{- end -}}
{{- define "content" -}}
<div class="page archive">
{{- /* Title */ -}}
<h2 class="single-title animated pulse faster">
{{- .Title | default (T .Section) | default .Section | printf (T "allSome") -}}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") -}}
</h2>
{{- /* Paginate */ -}}

View File

@@ -52,11 +52,14 @@
{{- $config = dict "lightGallery" $lightGalleryConfig | merge $config -}}
{{- end -}}
{{- $code := $params.code | default dict -}}
{{- $config = cond (ne $code.maxShownLines nil) $code.maxShownLines 10 | dict "maxShownLines" | dict "code" | merge $config -}}
{{- /* clipboard.js */ -}}
{{- if not $params.code | or (ne $params.code false) -}}
{{- if ne $code.copy false -}}
{{- $source := $cdn.clipboardJS | default "lib/clipboard/clipboard.min.js" -}}
{{- dict "source" $source "fingerprint" $fingerprint | dict "scratch" $.Scratch "data" | partial "scratch/script.html" -}}
{{- $config = T "copyToClipboard" | dict "title" | dict "clipboard" | merge $config -}}
{{- $config = T "copyToClipboard" | dict "copyTitle" | dict "code" | merge $config -}}
{{- end -}}
{{- /* Sharer.js */ -}}

View File

@@ -1,13 +1,13 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>
{{- .Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<description>
{{- .Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
{{- .Params.Title | default (T .Section) | default .Section | printf (T "allSome") }} | {{ .Site.Title -}}
</description>
<generator>Hugo -- gohugo.io</generator>
{{- with .Site.LanguageCode -}}

View File

@@ -67,21 +67,17 @@
{{- /* Static TOC */ -}}
{{- if $params.toc.enable -}}
<div class="toc" id="toc-static">
<details>
<summary>
<div class="toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details icon fas fa-angle-down"></i></span>
</div>
</summary>
<div class="toc-content" id="toc-content-static">
{{- $toc := .TableOfContents -}}
{{- $toc = partial "function/fontawesome.html" $toc -}}
{{- $toc = partial "function/ruby.html" $toc -}}
{{- $toc | safeHTML -}}
</div>
</details>
<div class="details toc" id="toc-static">
<div class="details-summary toc-title">
<span>{{ T "contents" }}</span>
<span><i class="details-icon fas fa-angle-down"></i></span>
</div>
<div class="details-content toc-content" id="toc-content-static">
{{- $toc := .TableOfContents -}}
{{- $toc = partial "function/fontawesome.html" $toc -}}
{{- $toc = partial "function/ruby.html" $toc -}}
{{- $toc | safeHTML -}}
</div>
</div>
{{- end -}}

View File

@@ -16,18 +16,20 @@
{{- if .IsNamedParams -}}
{{- $type := .Get "type" | default "note" -}}
{{- if .Get "details" -}}
<details class="admonition {{ $type }}">
<summary class="admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}<i class="details {{ $iconDetails }}"></i>
</summary>
<div class="admonition-content">
{{- $inner -}}
{{- if .Get "details" -}}
<div class="details admonition {{ $type }}">
<div class="details-summary admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}<i class="details-icon {{ $iconDetails }}"></i>
</div>
</details>
<div class="details-content">
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
</div>
{{- else -}}
<div class="admonition {{ $type }}">
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}</p>
<div class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get "title" | default (T $type) }}</div>
<div class="admonition-content">
{{- $inner -}}
</div>
@@ -36,17 +38,19 @@
{{- else -}}
{{- $type := .Get 0 | default "note" -}}
{{- if .Get 2 -}}
<details class="admonition {{ $type }}">
<summary class="admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}<i class="details {{ $iconDetails }}"></i>
</summary>
<div class="admonition-content">
{{- $inner -}}
<div class="details admonition {{ $type }}">
<div class="details-summary admonition-title">
<i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}<i class="details-icon {{ $iconDetails }}"></i>
</div>
</details>
<div class="details-content">
<div class="admonition-content">
{{- $inner -}}
</div>
</div>
</div>
{{- else -}}
<div class="admonition {{ $type }}">
<p class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}</p>
<div class="admonition-title"><i class="icon {{ index $iconMap $type | default (index $iconMap "note") }}"></i>{{ .Get 1 | default (T $type) }}</div>
<div class="admonition-content">
{{- $inner -}}
</div>

View File

@@ -1,13 +1,13 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>
{{- .Title }} | {{ T .Data.Singular | default .Data.Singular }} | {{ .Site.Title -}}
{{- .Params.Title }} | {{ T .Data.Singular | default .Data.Singular }} | {{ .Site.Title -}}
</title>
<link>
{{- .Permalink -}}
</link>
<description>
{{- .Title }} | {{ T .Data.Singular | default .Data.Singular }} | {{ .Site.Title -}}
{{- .Params.Title }} | {{ T .Data.Singular | default .Data.Singular }} | {{ .Site.Title -}}
</description>
<generator>Hugo -- gohugo.io</generator>
{{- with .Site.LanguageCode -}}