Skip to content

Commit

Permalink
feat: add the stats widget
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Aug 17, 2022
1 parent e8ab7ab commit d9d96cb
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ other = "Series"
[settings]
other = "Settings"

[stats]
other = "Stats"

[table_of_contents]
other = "Contents"

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ other = "专栏"
[settings]
other = "设置"

[stats]
other = "统计"

[table_of_contents]
other = "目录"

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-hans.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ other = "专栏"
[settings]
other = "设置"

[stats]
other = "统计"

[table_of_contents]
other = "目录"

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-hant.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ other = "專欄"
[settings]
other = "設置"

[stats]
other = "統計"

[table_of_contents]
other = "目錄"

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-hk.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ other = "專欄"
[settings]
other = "設置"

[stats]
other = "統計"

[table_of_contents]
other = "目錄"

Expand Down
3 changes: 3 additions & 0 deletions i18n/zh-tw.toml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ other = "專欄"
[settings]
other = "設置"

[stats]
other = "統計"

[table_of_contents]
other = "目錄"

Expand Down
1 change: 1 addition & 0 deletions layouts/partials/search/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="search-sidebar position-sticky px-2" style="top: 84px">
{{- partial "hooks/search/sidebar-begin" . }}
{{- partial "sidebar/stats" . }}
{{- partial "hooks/search/sidebar-end" . }}
</div>
29 changes: 29 additions & 0 deletions layouts/partials/sidebar/stats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- $icons := dict
"authors" "user"
"tags" "tags"
"series" "columns"
"categories" "folder"
}}
<div class="accordion stats">
<div class="accordion-item card row component">
<div class="accordion-header card-header border-0" id="stats-header">
<a class="accordion-button d-lg-none mb-2 collapsed shadow-none p-0 bg-transparent text-surface" type="button" data-bs-toggle="collapse" data-bs-target="#stats" aria-expanded="false" aria-controls="stats">
{{ i18n "stats" }}
</a>
</div>
<div class="card-body collapse accordion-collapse accordion-body d-lg-block" id="stats" aria-labelledby="stats-header">
<div class="row row-cols-5">
<a class="stat col d-flex flex-column align-items-center" title="{{ i18n "posts" }}" href="{{ absURL "/" }}">
<i class="stat-icon fas fa-fw fa-2x fa-file-alt mb-2"></i>
<span class="stat-count">{{ len $.Site.RegularPages }}</span>
</a>
{{- range $key, $value := $.Site.Taxonomies }}
<a class="stat col d-flex flex-column align-items-center" title="{{ i18n $key }}" href="{{ absLangURL (urlize $key) }}">
<i class="stat-icon fas fa-fw fa-2x fa-{{ index $icons $key }} mb-2"></i>
<span class="stat-count">{{ len $value.ByCount }}</span>
</a>
{{- end }}
</div>
</div>
</div>
</div>

0 comments on commit d9d96cb

Please sign in to comment.