Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/g1eny0ung/hugo-theme-dream.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYue Yang <g1enyy0ung@gmail.com>2021-07-03 10:40:10 +0300
committerYue Yang <g1enyy0ung@gmail.com>2021-07-03 10:43:45 +0300
commit30904c37813b16a7e41c2ab656029d02f72e8842 (patch)
tree82b9a45eb7761c88d2511b31284d5d0bb9ed0c21
parentd0578a6d45dce9aeb4c23e40c41ccae3b8241b25 (diff)
Update collapsibleTags
-rw-r--r--docs/params-configurations.md6
-rwxr-xr-xexampleSite/config.toml2
-rw-r--r--layouts/partials/collapsibleTags.html64
-rw-r--r--layouts/tags/terms.html41
4 files changed, 54 insertions, 59 deletions
diff --git a/docs/params-configurations.md b/docs/params-configurations.md
index 8724ccf..e5d365f 100644
--- a/docs/params-configurations.md
+++ b/docs/params-configurations.md
@@ -267,11 +267,11 @@ Make navbar fixed when scrolling.
### collapsibleTags = true
-Break tags into multiple levels by a collapsible manner.
+Make `/tags` page's tags collapsible.
-### collapseBySummary = false
+### collapseBySummary = true
-collapsibleTags collapses tags by .Title by default and by .Summary when collapseBySummary is true.
+If your posts contain duplicate titles, you can use this param to continue grouping the titles. The lowest level will use `.Summary` to render.
## Advanced
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 972387f..24b7dbf 100755
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -74,7 +74,7 @@ theme = "hugo-theme-dream"
# shareInAside = true
# fixedNav = true
# collapsibleTags = true
- # collapseBySummary = false
+ # collapseBySummary = true
# [params.advanced]
# customCSS = ["css/custom.css"]
diff --git a/layouts/partials/collapsibleTags.html b/layouts/partials/collapsibleTags.html
index 25b2545..e413306 100644
--- a/layouts/partials/collapsibleTags.html
+++ b/layouts/partials/collapsibleTags.html
@@ -1,38 +1,34 @@
<details>
- {{ $s := slice }}
- {{ range .context.WeightedPages }}
- {{ $s = $s | append .Title }}
- {{ end }}
- {{ $set := uniq $s }}
- {{ $len := len $set }}
- {{ $collapseBySummary := .collapseBySummary }}
- <summary>
- <h3 style="display: inline; color: #2E8B57;">{{ .context.Page.Title }}&nbsp</h3>
- <h3 style="display: inline;">{{- T "group" $len -}}</h3>
+ <summary class="ui header">
+ <a href="{{ .ctx.Page.RelPermalink }}">{{ .ctx.Page.Title }}</a>
+ {{- if not .collapseBySummary -}}&nbsp;{{ T "article" .ctx.Count }}{{- end -}}
</summary>
- <ul>
- {{ range .context.Pages.GroupBy "Title" }}
- {{ $len := len .Pages }}
- <details>
- <summary>
- <h3 style="display: inline; color: #2E8B57;">{{ .Key}}&nbsp</h3>
- <h3 style="display: inline;">{{- T "article" $len -}}</h3>
- </summary>
- <br>
- {{range .Pages}}
- <ul>
- <li>
- {{if $collapseBySummary}}
- <a href="{{ .RelPermalink }}">{{ safeHTML (substr .Summary 0 20)}}...</a>
- {{else}}
- <a href="{{ .RelPermalink }}">{{.Title}}...</a>
- {{end}}
- </li>
- </ul>
+ {{- if .collapseBySummary -}}
+
+ <ul>
+ {{ range .ctx.Pages.GroupBy "Title" }}
+ <details>
+ <summary>{{ .Key }}</summary>
+ <ul>
+ {{ range .Pages }}
+ <li>
+ <a href="{{ .RelPermalink }}" title="{{ .Summary }}">{{ substr (plainify .Summary) 0 25 }}...</a>
+ </li>
{{ end }}
- <br>
- </details>
- {{ end }}
- </ul>
-</details>
+ </ul>
+ </details>
+ {{ end }}
+ </ul>
+
+ {{- else -}}
+ <ul>
+ {{ range .ctx.Pages }}
+ <li>
+ <a href="{{ .Page.RelPermalink }}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+ </ul>
+
+ {{- end -}}
+</details>
diff --git a/layouts/tags/terms.html b/layouts/tags/terms.html
index 0ad11ef..c89cc05 100644
--- a/layouts/tags/terms.html
+++ b/layouts/tags/terms.html
@@ -7,36 +7,35 @@
{{ partial "header.html" . }}
{{ $collapsibleTags := .Site.Params.collapsibleTags}}
-{{ $collapseBySummary := .Site.Params.collapseBySummary}}
+{{ $collapseBySummary := .Site.Params.collapseBySummary }}
<div class="ui container">
<article class="ui segment dream-tags-section">
<h2 class="ui header">
{{- T "allTags" -}}
<span class="ui grey sub header">
- {{ if eq (len .Data.Terms) 1 }}
- {{- T "tag" 1 -}}
- {{ else }}
- {{- T "tag" (len .Data.Terms) -}}
- {{ end }}
+ {{- if eq (len .Data.Terms) 1 -}}
+ {{ T "tag" 1 }}
+ {{- else -}}
+ {{ T "tag" (len .Data.Terms) }}
+ {{- end -}}
</span>
</h2>
{{ range .Data.Terms.Alphabetical }}
- {{ if $collapsibleTags }}
- {{ partial "collapsibleTags.html" (dict "context" . "collapseBySummary" $collapseBySummary)}}
- {{ else }}
- <h3 class="ui header">
- <a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a>&nbsp;
- {{- T "article" .Count -}}
- </h3>
- <ul>
- {{ range .Pages }}
- <li>
- <a href="{{ .RelPermalink }}">{{ .Title }}</a>
- </li>
- {{ end }}
- </ul>
- {{ end }}
+ {{ if $collapsibleTags }}
+ {{ partial "collapsibleTags.html" (dict "ctx" . "collapseBySummary" $collapseBySummary) }}
+ {{ else }}
+ <h3 class="ui header">
+ <a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a>&nbsp;{{- T "article" .Count -}}
+ </h3>
+ <ul>
+ {{ range .Pages }}
+ <li>
+ <a href="{{ .RelPermalink }}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+ </ul>
+ {{ end }}
{{ end }}
</article>
</div>