Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jul 12, 2021
1 parent acf53d9 commit 0217044
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 50 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ As the example site shown, the configuration are separated into multiple files,
| `color` | String | - | Color mode, `light`, `dark` or dynamic. Default to dynamic.
| `palette` | String | - | Default palette. This will take effect after clearing the Cookie.
| `palettes` | Array | **ALL** | Available palettes. You can disable it by setting it to empty `[]`.
| `featuredPostCount` | Integer | `5` | The number of featured posts shown in sidebar.
| `recentPostCount` | Integer | `5` | The number of recent posts shown in sidebar.
| `relatedPostCount` | Integer | `5` | The number of related posts.
| `categoryCount` | Integer | `10` | The number of categories shown in sidebar.
| `tagCount` | Integer | `10` | The number of tags shown in sidebar.
| `featuredPostCount` | Integer/Boolean | `5` | The number of featured posts shown in sidebar. Turn off by setting it to `false`.
| `recentPostCount` | Integer/Boolean | `5` | The number of recent posts shown in sidebar. Turn off by setting it to `false`.
| `relatedPostCount` | Integer/Boolean | `5` | The number of related posts. Turn off by setting it to `false`.
| `categoryCount` | Integer/Boolean | `10` | The number of categories shown in sidebar. Turn off by setting it to `false`.
| `tagCount` | Integer/Boolean | `10` | The number of tags shown in sidebar. Turn off by setting it to `false`.
| `seriesCount` | Integer | `10` | The number of series shown in sidebar.
| `fullWidth` | Boolean | `false` | Full width.
| `fixedHeader` | Boolean | `true` | Turn on/off fixed header.
Expand Down
12 changes: 6 additions & 6 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ $ hugo new content/zh-CN/newpost.md
| `color` | String | - | 颜色风格, `light``dark` 或者 dynamic(默认)。
| `palette` | String | - | 默认配色,清理 Cookie 后生效。
| `palettes` | Array | **ALL** | 可选配色,如需禁用此选项,可将其设为空值 `[]`
| `featuredPostCount` | Integer | `5` | 精选文章数
| `recentPostCount` | Integer | `5` | 最近文章数
| `relatedPostCount` | Integer | `5` | 相关文章数
| `categoryCount` | Integer | `10` | 分类数
| `tagCount` | Integer | `10` | 标签数
| `seriesCount` | Integer | `10` | 专栏数
| `featuredPostCount` | Integer/Boolean | `5` | 精选文章数`false` 则隐藏。
| `recentPostCount` | Integer/Boolean | `5` | 最近文章数`false` 则隐藏。
| `relatedPostCount` | Integer/Boolean | `5` | 相关文章数`false` 则隐藏。
| `categoryCount` | Integer/Boolean | `10` | 分类数`false` 则隐藏。
| `tagCount` | Integer/Boolean | `10` | 标签数`false` 则隐藏。
| `seriesCount` | Integer/Boolean | `10` | 专栏数`false` 则隐藏。
| `fullWidth` | Boolean | `false` | 是否全宽
| `fixedHeader` | Boolean | `true` | 是否固定头部
| `reward` | Object | - | 打赏
Expand Down
12 changes: 6 additions & 6 deletions README.zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ $ hugo new content/zh-CN/newpost.md
| `color` | String | - | 顏色風格, `light``dark` 或者 dynamic(默認)。
| `palette` | String | - | 預設配色,清理 Cookie 後生效。
| `palettes` | Array | **ALL** | 可選配色,如需禁用此選項,可將其設為空值 `[]`
| `featuredPostCount` | Integer | `5` | 精選文章數
| `recentPostCount` | Integer | `5` | 最近文章數
| `relatedPostCount` | Integer | `5` | 相關文章數
| `categoryCount` | Integer | `10` | 分類數
| `tagCount` | Integer | `10` | 標籤數
| `seriesCount` | Integer | `10` | 專欄數
| `featuredPostCount` | Integer/Boolean | `5` | 精選文章數`false` 則隱藏。
| `recentPostCount` | Integer/Boolean | `5` | 最近文章數`false` 則隱藏。
| `relatedPostCount` | Integer/Boolean | `5` | 相關文章數`false` 則隱藏。
| `categoryCount` | Integer/Boolean | `10` | 分類數`false` 則隱藏。
| `tagCount` | Integer/Boolean | `10` | 標籤數`false` 則隱藏。
| `seriesCount` | Integer/Boolean | `10` | 專欄數`false` 則隱藏。
| `fullWidth` | Boolean | `false` | 是否全寬
| `fixedHeader` | Boolean | `true` | 是否固定頭部
| `reward` | Object | - | 打賞
Expand Down
12 changes: 6 additions & 6 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ googleAdsense = ""

# poweredBy = false # Whether to show powered by.

# featuredPostCount = 10 # The number of featured posts shown in sidebar.
# recentPostCount = 10 # The number of recent posts shown in sidebar.
# relatedPostCount = 10 # The number of related posts.
# categoryCount = 10 # The number of categories shown in sidebar.
# tagCount = 10 # The number of tags shown in sidebar.
# seriesCount = 10 # The number of series shown in sidebar.
# featuredPostCount = 10 # The number of featured posts shown in sidebar. Turn off by setting it to false.
# recentPostCount = 10 # The number of recent posts shown in sidebar. Turn off by setting it to false.
# relatedPostCount = 10 # The number of related posts. Turn off by setting it to false.
# categoryCount = 10 # The number of categories shown in sidebar. Turn off by setting it to false.
# tagCount = 10 # The number of tags shown in sidebar. Turn off by setting it to false.
# seriesCount = 10 # The number of series shown in sidebar. Turn off by setting it to false.

# Custom CSS and JS
customCSS = []
Expand Down
21 changes: 12 additions & 9 deletions layouts/partials/sidebar/featured-posts.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{{- $featuredPosts := first (default 5 .Site.Params.featuredPostCount) (where (where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.featured" "eq" true) -}}
{{- with $featuredPosts -}}
<section class="featured-posts row surface">
<h4>{{ T "featured_posts" }}</h4>
<ul>
{{- range . -}}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{- $count := default 5 .Site.Params.featuredPostCount -}}
{{- if $count -}}
{{- $featuredPosts := first $count (where (where site.RegularPages "Type" "in" site.Params.mainSections) ".Params.featured" "eq" true) -}}
{{- with $featuredPosts -}}
<section class="featured-posts row surface">
<h4>{{ T "featured_posts" }}</h4>
<ul>
{{- range . -}}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{- end -}}
</ul>
</section>
{{- end -}}
</ul>
</section>
{{- end -}}
5 changes: 4 additions & 1 deletion layouts/partials/sidebar/recent-posts.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{- $count := default 5 .Site.Params.recentPostCount -}}
{{- if $count -}}
<section class="recent-posts row surface">
<h4>{{ T "recent_posts" }}</h4>
<ul>
{{- range first (default 5 .Site.Params.recentPostCount) (where site.RegularPages "Type" "in" site.Params.mainSections) -}}
{{- range first $count (where site.RegularPages "Type" "in" site.Params.mainSections) -}}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{- end -}}
</ul>
</section>
{{- end -}}
36 changes: 19 additions & 17 deletions layouts/partials/sidebar/taxonomies.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
{{- range $key, $value := .Site.Taxonomies -}}
{{- $countParams := dict "categories" "categoryCount" "tags" "tagCount" "series" "seriesCount" -}}
{{- $param := default "" (index $countParams $key) -}}
{{- $taxonomyCount := default 10 ($.Site.Param $param) -}}
{{- with $value.ByCount -}}
<section class="taxonomy-{{ $key }} row surface">
<h4>
<a href="{{ absLangURL (urlize $key) }}">{{ T $key }}</a>
</h4>
<div>
{{- range $idx, $taxonomy := . -}}
{{- if lt $idx $taxonomyCount -}}
<a href="{{ $taxonomy.Page.Permalink }}" class="post-taxonomy rounded btn btn-sm me-2 mb-2" title="{{ $taxonomy.Page.Title }}">
{{ $taxonomy.Page.Title }} <span class="badge rounded-pill">{{ $taxonomy.Count }}</span>
</a>
{{- $countParams := dict "categories" "categoryCount" "tags" "tagCount" "series" "seriesCount" -}}
{{- $param := default "" (index $countParams $key) -}}
{{- $taxonomyCount := default 10 ($.Site.Param $param) -}}
{{- if $taxonomyCount -}}
{{- with $value.ByCount -}}
<section class="taxonomy-{{ $key }} row surface">
<h4>
<a href="{{ absLangURL (urlize $key) }}">{{ T $key }}</a>
</h4>
<div>
{{- range $idx, $taxonomy := . -}}
{{- if lt $idx $taxonomyCount -}}
<a href="{{ $taxonomy.Page.Permalink }}" class="post-taxonomy rounded btn btn-sm me-2 mb-2" title="{{ $taxonomy.Page.Title }}">
{{ $taxonomy.Page.Title }} <span class="badge rounded-pill">{{ $taxonomy.Count }}</span>
</a>
{{- end -}}
{{- end -}}
</div>
</section>
{{- end -}}
{{- end -}}
</div>
</section>
{{- end -}}
{{- end -}}

0 comments on commit 0217044

Please sign in to comment.