Skip to content

Commit

Permalink
feat: add the sidebar.width parameter, which accepts percentage value…
Browse files Browse the repository at this point in the history
…, such as .3 (equals to 30%), 40%
  • Loading branch information
razonyang committed Dec 14, 2023
1 parent 68b9197 commit 8f6847e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions assets/hb/modules/blog/scss/_sidebar.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@function hb-blog-sidebar-width-fr($fullWidth) {
@return #{$fullWidth * $hb-blog-sidebar-width}fr;
}

@if $hb-blog-sidebar {
.hb-blog-main-container {
@include media-breakpoint-up(lg) {
Expand All @@ -6,18 +10,18 @@

@if $hb-blog-sidebar-position == end {
grid-template-areas: "main sidebar";
grid-template-columns: minmax(0, 5fr) 2fr;
grid-template-columns: minmax(0, 5fr) hb-blog-sidebar-width-fr(5);
} @else {
grid-template-areas: "sidebar main";
grid-template-columns: 2fr minmax(0, 5fr);
grid-template-columns: hb-blog-sidebar-width-fr(5) minmax(0, 5fr);
}
}

@include media-breakpoint-up(xl) {
@if $hb-blog-sidebar-position == end {
grid-template-columns: minmax(0, 7fr) 2fr;
grid-template-columns: minmax(0, 7fr) hb-blog-sidebar-width-fr(7);
} @else {
grid-template-columns: 2fr minmax(0, 7fr);
grid-template-columns: hb-blog-sidebar-width-fr(7) minmax(0, 7fr);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions assets/hb/modules/blog/scss/variables.tmpl.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{- $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-sidebar-width: {{ default 0.35 site.Params.hb.blog.sidebar.width }};
$hb-blog-home-pinned-posts-pos: '{{ default "" site.Params.hb.blog.home.pinned_posts_position }}';

// ToC
Expand Down
1 change: 1 addition & 0 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pinned_posts_position = ""

[params.hb.blog.sidebar]
position = "start"
width = 0.35

[params.hb.blog.toc]
position = "end" # start, end or content.

0 comments on commit 8f6847e

Please sign in to comment.