add side panel
This commit is contained in:
@ -13,4 +13,8 @@ layout:
|
|||||||
|
|
||||||
search:
|
search:
|
||||||
hint: "Search"
|
hint: "Search"
|
||||||
cancel: "Cancel"
|
cancel: "Cancel"
|
||||||
|
|
||||||
|
panel:
|
||||||
|
lastmod: "Recently Updated"
|
||||||
|
trending_tags: "Trending Tags"
|
||||||
|
@ -13,4 +13,8 @@ layout:
|
|||||||
|
|
||||||
search:
|
search:
|
||||||
hint: "搜索"
|
hint: "搜索"
|
||||||
cancel: "取消"
|
cancel: "取消"
|
||||||
|
|
||||||
|
panel:
|
||||||
|
lastmod: "最近更新"
|
||||||
|
trending_tags: "热门标签"
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
<!-- panel -->
|
<!-- panel -->
|
||||||
<aside aria-label="Panel" id="panel-wrapper" class="col-xl-3 ps-2 text-muted">
|
<aside aria-label="Panel" id="panel-wrapper" class="col-xl-3 ps-2 text-muted">
|
||||||
<div class="access">
|
<div class="access">
|
||||||
|
{{ partialCached "update-list.html" . }}
|
||||||
|
{{ partialCached "trending-tags.html" . }}
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
|
32
layouts/partials/trending-tags.html
Normal file
32
layouts/partials/trending-tags.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<!-- The trending tags list -->
|
||||||
|
{{ $MAX := 10 }}
|
||||||
|
{{ $allTags := slice }}
|
||||||
|
|
||||||
|
<!-- Get all tags with their counts -->
|
||||||
|
{{ range $name, $taxonomy := .Site.Taxonomies.tags }}
|
||||||
|
{{ $allTags = $allTags | append (dict "name" $name "count" $taxonomy.Count) }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
<!-- Sort by count (descending) and then by name (ascending) -->
|
||||||
|
{{ $sortedTags := sort $allTags "count" "desc" }}
|
||||||
|
{{ $sortedTags = sort $sortedTags "name" "asc" }}
|
||||||
|
|
||||||
|
<!-- Get top N unique tags -->
|
||||||
|
{{ $trendingTags := slice }}
|
||||||
|
{{ range $i, $tag := $sortedTags }}
|
||||||
|
{{ if lt (len $trendingTags) $MAX }}
|
||||||
|
{{ $trendingTags = $trendingTags | append $tag.name }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if gt (len $trendingTags) 0 }}
|
||||||
|
<section>
|
||||||
|
<h2 class="panel-heading">{{ T "panel.trending_tags" }}</h2>
|
||||||
|
<div class="d-flex flex-wrap mt-3 mb-1 me-3">
|
||||||
|
{{ range $trendingTags }}
|
||||||
|
{{ $url := printf "/tags/%s/" (urlize .) }}
|
||||||
|
<a class="post-tag btn btn-outline-primary" href="{{ $url | relURL }}">{{ . }}</a>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{{ end }}
|
29
layouts/partials/update-list.html
Normal file
29
layouts/partials/update-list.html
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<!-- Get 5 last posted/updated posts -->
|
||||||
|
{{ $MAX_SIZE := 5 }}
|
||||||
|
{{ $all_posts := slice }}
|
||||||
|
|
||||||
|
{{ range $index, $post := where site.RegularPages "Type" "in" site.Params.mainSections }}
|
||||||
|
{{ $datetime := $post.Lastmod | default $post.Date }}
|
||||||
|
{{ $elem := printf "%s::%d" ($datetime.Format "20060102150405") $index }}
|
||||||
|
{{ $all_posts = $all_posts | append $elem }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $all_posts = sort $all_posts "value" "desc" }}
|
||||||
|
{{ $update_list := first $MAX_SIZE $all_posts }}
|
||||||
|
|
||||||
|
{{ if gt (len $update_list) 0 }}
|
||||||
|
<section id="access-lastmod">
|
||||||
|
<h2 class="panel-heading">{{ T "panel.lastmod" }}</h2>
|
||||||
|
<ul class="content list-unstyled ps-0 pb-1 ms-1 mt-2">
|
||||||
|
{{ range $item := $update_list }}
|
||||||
|
{{ $parts := split $item "::" }}
|
||||||
|
{{ $index := index $parts 1 | int }}
|
||||||
|
{{ $post := index (where site.RegularPages "Type" "in" site.Params.mainSections) $index }}
|
||||||
|
<li class="text-truncate lh-lg">
|
||||||
|
<a href="{{ $post.RelPermalink }}">{{ $post.Title }}</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
<!-- #access-lastmod -->
|
||||||
|
{{ end }}
|
Reference in New Issue
Block a user