Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the toc page parameter, when false then hide the ToC #646

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 25 additions & 19 deletions assets/hb/modules/blog/scss/post/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@
grid-gap: 1rem;
grid-template-areas:
"intro"
"toc"
"main";
grid-template-rows: auto auto 1fr;

@include media-breakpoint-up(lg) {
@if $hb-blog-toc-position == 'start' {
grid-template-areas:
"toc intro"
"toc main";
/* stylelint-disable declaration-block-no-redundant-longhand-properties */
grid-template-rows: 1fr auto;
grid-template-columns: 1fr 4fr;
/* stylelint-enable declaration-block-no-redundant-longhand-properties */
} @else if $hb-blog-toc-position == 'end' {
grid-template-areas:
"intro toc"
"main toc";
/* stylelint-disable declaration-block-no-redundant-longhand-properties */
grid-template-rows: auto 1fr;
grid-template-columns: 4fr 1fr;
/* stylelint-enable declaration-block-no-redundant-longhand-properties */
&.toc {
grid-template-areas:
"intro"
"toc"
"main";
grid-template-rows: auto auto 1fr;

@include media-breakpoint-up(lg) {
@if $hb-blog-toc-position == 'start' {
grid-template-areas:
"toc intro"
"toc main";
/* stylelint-disable declaration-block-no-redundant-longhand-properties */
grid-template-rows: 1fr auto;
grid-template-columns: 1fr 4fr;
/* stylelint-enable declaration-block-no-redundant-longhand-properties */
} @else if $hb-blog-toc-position == 'end' {
grid-template-areas:
"intro toc"
"main toc";
/* stylelint-disable declaration-block-no-redundant-longhand-properties */
grid-template-rows: auto 1fr;
grid-template-columns: 4fr 1fr;
/* stylelint-enable declaration-block-no-redundant-longhand-properties */
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions layouts/partials/hb/modules/blog/single.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="hb-blog-main-container">
<div class="hb-blog-main">
{{ partial "hugopress/functions/render-hooks" (dict "Name" "hb-blog-main-begin" "Page" .) }}
<div class="hb-blog-post position-relative">
{{- $toc := default true .Params.toc }}
<div class="hb-blog-post position-relative{{ cond $toc ` toc` `` }}">
<div class="hb-blog-post-intro hb-module mb-2">
<h1 class="hb-blog-post-title text-break">{{ .Title }}</h1>
<div class="hb-blog-post-meta">
Expand All @@ -15,7 +16,7 @@ <h1 class="hb-blog-post-title text-break">{{ .Title }}</h1>
{{- end }}
</div>
{{- $tocPos := default "start" site.Params.hb.blog.toc.position }}
{{- if ne $tocPos "content" }}
{{- if and $toc (ne $tocPos "content") }}
<div class="hb-blog-post-toc text-body-secondary position-sticky overflow-y-auto">
{{- partialCached "hb/modules/blog/post/toc" . . }}
</div>
Expand Down