Skip to content

Commit

Permalink
feat: add the sidebar posts module
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jun 19, 2023
1 parent 390a9ff commit f659bed
Show file tree
Hide file tree
Showing 9 changed files with 173 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.hb-blog-sidebar-posts {
.hb-blog-post-title-link {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.hb-blog-post-card-img,
.hb-blog-post-card-img-none {
height: 120px;
}
}
17 changes: 17 additions & 0 deletions modules/sidebar/posts/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/hbstack/blog/modules/sidebar/posts

go 1.19

require (
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20003 // indirect
github.com/hbstack/blog v0.14.0 // indirect
github.com/hbstack/footer v0.2.1 // indirect
github.com/hbstack/header v0.1.17 // indirect
github.com/hbstack/slide v0.2.0 // indirect
github.com/hugomods/base v0.1.0 // indirect
github.com/hugomods/hugopress v0.2.0 // indirect
github.com/hugomods/icons v0.6.0 // indirect
github.com/hugomods/icons/vendors/simple-icons v1.0.2 // indirect
github.com/hugomods/seo/modules/base v0.1.0 // indirect
github.com/twbs/icons v1.10.5 // indirect
)
24 changes: 24 additions & 0 deletions modules/sidebar/posts/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20003 h1:pt/JGVD5YYRsVVijOHPZI6YKTUvbR4e0hgV9B0S6rbI=
github.com/gohugoio/hugo-mod-bootstrap-scss/v5 v5.20300.20003/go.mod h1:mvM05r93HiefwoaxQTaYiJxtJAhTebwQtU1Xh/J+Okk=
github.com/gohugoio/hugo-mod-jslibs-dist/popperjs/v2 v2.21100.20000/go.mod h1:mFberT6ZtcchrsDtfvJM7aAH2bDKLdOnruUHl0hlapI=
github.com/hbstack/blog v0.14.0 h1:MbGBGvY1rb/v3V3zzRGxM+pX6rhh+ylN8m++Gxc3edo=
github.com/hbstack/blog v0.14.0/go.mod h1:qM7rXyw88WzFhMzXlq/gz3IrO7OUkRqqtOcpafnmUMQ=
github.com/hbstack/footer v0.2.1 h1:GZbSRcGNMeKAiDLeai0cPaEnztkDBraTNQqe2uap944=
github.com/hbstack/footer v0.2.1/go.mod h1:ldb4b95D/7NVWQWFTIngasypCA+QQQRj1I+1BEyOi/c=
github.com/hbstack/header v0.1.17 h1:lIZuV4+WGsLWxWxEitec3ItAryQoGELpvNHkoYw25tY=
github.com/hbstack/header v0.1.17/go.mod h1:YEYnlqmhotkQdFbSzN/ZQT55kLLfMdvVVIzEDMFgTz4=
github.com/hbstack/slide v0.2.0 h1:0D8Vt4bxtFCNpozRu0WDMz0kgOy60Gk1aJKAZSPUnik=
github.com/hbstack/slide v0.2.0/go.mod h1:7fBmuBpoxrmP+dQPArVyX80LTQOWCm8z7Rf38nzDlzE=
github.com/hugomods/base v0.1.0 h1:3o9Y85BvXHjkYzZfswM/EtthQ8GOYKN8aXHkIWqu3/8=
github.com/hugomods/base v0.1.0/go.mod h1:hnWCPbVxuhXBwdFax3mmbMlWKmIo/7OP36MCLOyHtT4=
github.com/hugomods/hugopress v0.2.0 h1:Y9emu6wDnPsr7Rk0VyxWi5KEWreaFxUxPFAeG6euFpk=
github.com/hugomods/hugopress v0.2.0/go.mod h1:CRYvr60xOkZOf4Atkuj+uEj2EH5pjJ39Ws3aJAkoMkA=
github.com/hugomods/icons v0.6.0 h1:G6RU93okhPPRDh/jqcew9gwkcYpSpg0rCBv4S6yUAFw=
github.com/hugomods/icons v0.6.0/go.mod h1:cIkSvK6W0q6N4U6n9KGz+QfRWQXAW0INd+1P31gPNGg=
github.com/hugomods/icons/vendors/simple-icons v1.0.2 h1:ZeJhUAweQmS/YtRHoVlFhIlH0tqHjMsPEXKSenwPpUM=
github.com/hugomods/icons/vendors/simple-icons v1.0.2/go.mod h1:H/2FX6ppiVXZ0vZZGAsLWcKSXwWScWLj+jg/jJhOgKk=
github.com/hugomods/seo/modules/base v0.1.0 h1:ZEkWuYeRJeQakBkBThO3N3lmGzOZoPixs4pDugJXfJk=
github.com/hugomods/seo/modules/base v0.1.0/go.mod h1:qfm1Vga0eGxL+Szgz8Jopm+NtJ5PGov2a2dikTg1qSg=
github.com/twbs/bootstrap v5.3.0+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=
github.com/twbs/icons v1.10.5 h1:F9uvW7cGfDBAautw5aeCmnB3hw4vv3aEQGbHnzcQKaE=
github.com/twbs/icons v1.10.5/go.mod h1:GnRlymgVWp5iVJCMa0Me5b6tFyGpVc2bSxPMRGIJmyA=
11 changes: 11 additions & 0 deletions modules/sidebar/posts/hugo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[[module.imports]]
path = "github.com/hbstack/blog"

[[module.imports]]
path = "github.com/hbstack/slide"

[params.hugopress.modules.hb-blog-sidebar-posts.hooks.hb-blog-sidebar]

[params.hb.blog.sidebar.posts]
recent_count = 5
featured_count = 5
5 changes: 5 additions & 0 deletions modules/sidebar/posts/i18n/en.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[featured_posts]
other = "Featured"

[recent_posts]
other = "Recent"
5 changes: 5 additions & 0 deletions modules/sidebar/posts/i18n/zh-hans.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[featured_posts]
other = "精选文章"

[recent_posts]
other = "最近文章"
5 changes: 5 additions & 0 deletions modules/sidebar/posts/i18n/zh-hant.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[featured_posts]
other = "精選文章"

[recent_posts]
other = "最近文章"
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{{- $params := site.Params.hb.blog.sidebar.posts }}
{{- $recentPosts := slice }}
{{- if $params.recent_count }}
{{- $recentPosts = first $params.recent_count site.RegularPages.ByDate.Reverse }}
{{- end }}

{{- $featuredPosts := slice }}
{{- if $params.featured_count }}
{{- $featuredPosts = first $params.featured_count (where site.RegularPages ".Params.featured" "eq" true) }}
{{- end }}

{{- if or $featuredPosts $recentPosts }}
<div class="hb-blog-sidebar-posts hb-module">
<ul class="nav nav-pills nav-fill" role="tablist">
{{- if $featuredPosts }}
<li class="nav-item" role="presentation">
<button
class="nav-link active"
id="featured-posts-tab"
data-bs-toggle="tab"
data-bs-target="#featured-posts"
type="button"
role="tab"
aria-controls="featured-posts"
aria-selected="true">
{{ i18n "featured_posts" }}
</button>
</li>
{{- end }}
{{- if $recentPosts }}
<li class="nav-item" role="presentation">
<button
class="nav-link{{ cond (not $featuredPosts) ` active` `` }}"
id="recent-posts-tab"
data-bs-toggle="tab"
data-bs-target="#recent-posts"
type="button"
role="tab"
aria-controls="recent-posts"
aria-selected="true">
{{ i18n "recent_posts" }}
</button>
</li>
{{- end }}
</ul>

<div class="tab-content mt-3">
{{- with $featuredPosts }}
<div
class="tab-pane active"
id="featured-posts"
role="tabpanel"
aria-labelledby="featured-posts-tab"
tabindex="0">
<div class="slide">
<div class="slide-inner row row-cols-1">
{{- range . }}
<div class="slide-item px-0">
{{- $ctx := dict "Page" . "Meta" false "Summary" false }}
{{ partial "hb/modules/blog/post/card" $ctx }}
</div>
{{- end }}
</div>
{{ partialCached "hb/modules/slide/controls" . }}
</div>
</div>
{{- end }}
{{- with $recentPosts }}
<div
class="tab-pane slide{{ cond (not $featuredPosts) ` active` `` }}"
id="recent-posts"
role="tabpanel"
aria-labelledby="recent-posts-tab"
tabindex="0">
<div class="slide">
<div class="slide-inner row row-cols-1">
{{- range . }}
<div class="slide-item px-0">
{{- $ctx := dict "Page" . "Meta" false "Summary" false }}
{{ partial "hb/modules/blog/post/card" $ctx }}
</div>
{{- end }}
</div>
{{ partialCached "hb/modules/slide/controls" . }}
</div>
</div>
{{- end }}
</div>
</div>
{{- end }}
4 changes: 4 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"modules/heading-sign",
"modules/post-nav",
"modules/related-posts",
"modules/sidebar/posts",
"modules/staticman",
"modules/toc-scrollspy",
"modules/twikoo",
Expand Down Expand Up @@ -56,6 +57,9 @@
"modules/related-posts": {
"component": "modules/related-posts"
},
"modules/sidebar/posts": {
"component": "modules/sidebar/posts"
},
"modules/staticman": {
"component": "modules/staticman"
},
Expand Down

0 comments on commit f659bed

Please sign in to comment.