From b366c215c0d9fa0c74d73e13e9861c5c67732664 Mon Sep 17 00:00:00 2001 From: razonyang Date: Thu, 14 Dec 2023 12:17:10 +0800 Subject: [PATCH] feat: add the sidebar.position parameter When end, place the sidebar on the right. --- assets/hb/modules/blog/scss/_sidebar.scss | 16 +++++++++++++--- assets/hb/modules/blog/scss/variables.tmpl.scss | 1 + hugo.toml | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/assets/hb/modules/blog/scss/_sidebar.scss b/assets/hb/modules/blog/scss/_sidebar.scss index e82d9a0f..a2c2ef3e 100644 --- a/assets/hb/modules/blog/scss/_sidebar.scss +++ b/assets/hb/modules/blog/scss/_sidebar.scss @@ -3,12 +3,22 @@ @include media-breakpoint-up(lg) { display: grid; grid-gap: 1rem; - grid-template-areas: "sidebar main"; - grid-template-columns: 2fr minmax(0, 5fr); + + @if $hb-blog-sidebar-position == end { + grid-template-areas: "main sidebar"; + grid-template-columns: minmax(0, 5fr) 2fr; + } @else { + grid-template-areas: "sidebar main"; + grid-template-columns: 2fr minmax(0, 5fr); + } } @include media-breakpoint-up(xl) { - grid-template-columns: 2fr minmax(0, 7fr); + @if $hb-blog-sidebar-position == end { + grid-template-columns: minmax(0, 7fr) 2fr; + } @else { + grid-template-columns: 2fr minmax(0, 7fr); + } } } diff --git a/assets/hb/modules/blog/scss/variables.tmpl.scss b/assets/hb/modules/blog/scss/variables.tmpl.scss index df930af9..9c208cff 100644 --- a/assets/hb/modules/blog/scss/variables.tmpl.scss +++ b/assets/hb/modules/blog/scss/variables.tmpl.scss @@ -1,3 +1,4 @@ {{- $hasSidebar := partialCached "hb/modules/blog/functions/has-sidebar" . }} $hb-blog-sidebar: {{ $hasSidebar }}; +$hb-blog-sidebar-position: {{ default "start" site.Params.hb.blog.sidebar.position }}; $hb-blog-home-pinned-posts-pos: '{{ default "" site.Params.hb.blog.home.pinned_posts_position }}'; diff --git a/hugo.toml b/hugo.toml index 203c2ac5..bc62ffaf 100644 --- a/hugo.toml +++ b/hugo.toml @@ -39,3 +39,6 @@ paginate = 30 [params.hb.blog.home] pinned_posts_position = "" # taxonomies_style = 'toggle' + +[params.hb.blog.sidebar] +position = "start"