diff --git a/modules/sidebar/posts/assets/hb/modules/blog-sidebar-posts/scss/index.scss b/modules/sidebar/posts/assets/hb/modules/blog-sidebar-posts/scss/index.scss new file mode 100644 index 00000000..3e1b2470 --- /dev/null +++ b/modules/sidebar/posts/assets/hb/modules/blog-sidebar-posts/scss/index.scss @@ -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; + } +} diff --git a/modules/sidebar/posts/go.mod b/modules/sidebar/posts/go.mod new file mode 100644 index 00000000..9062c147 --- /dev/null +++ b/modules/sidebar/posts/go.mod @@ -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 +) diff --git a/modules/sidebar/posts/go.sum b/modules/sidebar/posts/go.sum new file mode 100644 index 00000000..17d1fb91 --- /dev/null +++ b/modules/sidebar/posts/go.sum @@ -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= diff --git a/modules/sidebar/posts/hugo.toml b/modules/sidebar/posts/hugo.toml new file mode 100644 index 00000000..ccf0df4a --- /dev/null +++ b/modules/sidebar/posts/hugo.toml @@ -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 diff --git a/modules/sidebar/posts/i18n/en.toml b/modules/sidebar/posts/i18n/en.toml new file mode 100644 index 00000000..f229f526 --- /dev/null +++ b/modules/sidebar/posts/i18n/en.toml @@ -0,0 +1,5 @@ +[featured_posts] +other = "Featured" + +[recent_posts] +other = "Recent" diff --git a/modules/sidebar/posts/i18n/zh-hans.toml b/modules/sidebar/posts/i18n/zh-hans.toml new file mode 100644 index 00000000..2a51a4d8 --- /dev/null +++ b/modules/sidebar/posts/i18n/zh-hans.toml @@ -0,0 +1,5 @@ +[featured_posts] +other = "精选文章" + +[recent_posts] +other = "最近文章" diff --git a/modules/sidebar/posts/i18n/zh-hant.toml b/modules/sidebar/posts/i18n/zh-hant.toml new file mode 100644 index 00000000..794ce8cb --- /dev/null +++ b/modules/sidebar/posts/i18n/zh-hant.toml @@ -0,0 +1,5 @@ +[featured_posts] +other = "精選文章" + +[recent_posts] +other = "最近文章" diff --git a/modules/sidebar/posts/layouts/partials/hugopress/modules/hb-blog-sidebar-posts/hooks/hb-blog-sidebar.html b/modules/sidebar/posts/layouts/partials/hugopress/modules/hb-blog-sidebar-posts/hooks/hb-blog-sidebar.html new file mode 100644 index 00000000..4741de85 --- /dev/null +++ b/modules/sidebar/posts/layouts/partials/hugopress/modules/hb-blog-sidebar-posts/hooks/hb-blog-sidebar.html @@ -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 }} +
+{{- end }} diff --git a/release-please-config.json b/release-please-config.json index 9a18967b..e94d2a7a 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -26,6 +26,7 @@ "modules/heading-sign", "modules/post-nav", "modules/related-posts", + "modules/sidebar/posts", "modules/staticman", "modules/toc-scrollspy", "modules/twikoo", @@ -56,6 +57,9 @@ "modules/related-posts": { "component": "modules/related-posts" }, + "modules/sidebar/posts": { + "component": "modules/sidebar/posts" + }, "modules/staticman": { "component": "modules/staticman" },