Added the option to show the sidebar on other pages (#2)

Added settings to show the sidebar on posts and other pages, in addition to the home page.
This commit is contained in:
Leon Mika 2024-12-26 14:32:20 +11:00 committed by GitHub
parent d70e270ed0
commit 8a80ab665d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View file

@ -1,4 +1,8 @@
{{ if .IsHome -}}
{{ $isPost := eq .Page.Type "post" -}}
{{ $showOnPosts := $.Site.Params.sidebar_show_on_posts -}}
{{ $showOnPages := $.Site.Params.sidebar_show_on_pages -}}
{{ $shouldShowSidebar := or .IsHome (and $showOnPosts $isPost) (and $showOnPages (not $isPost)) -}}
{{ if $shouldShowSidebar -}}
<div class="sidebar">
{{ if templates.Exists "partials/sidebar.html" }}
{{ partial "sidebar.html" . }}

View file

@ -1,8 +1,20 @@
{
"version": "1.1.1",
"version": "1.2.0",
"title": "Sidebar for Tiny Theme",
"description": "Adds a sidebar to a blog using Tiny Theme",
"includes": [
"/sidebar.css"
],
"fields": [
{
"field": "params.sidebar_show_on_posts",
"label": "Show sidebar on posts",
"type": "boolean"
},
{
"field": "params.sidebar_show_on_pages",
"label": "Show sidebar on other pages",
"type": "boolean"
}
]
}