From e965aa45b3b19faaf8767a40cbdac125396bcfc7 Mon Sep 17 00:00:00 2001 From: welpo Date: Sun, 3 Sep 2023 22:07:45 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20allow=20social=20media=20ca?= =?UTF-8?q?rds=20on=20sections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/macros/settings.html | 8 +++++--- templates/partials/header.html | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/templates/macros/settings.html b/templates/macros/settings.html index 60ec24f39..923720431 100644 --- a/templates/macros/settings.html +++ b/templates/macros/settings.html @@ -9,10 +9,12 @@ - default_global_value: The setting's default value. #} -{% macro evaluate_setting_priority(setting, page, default_global_value="") %} +{% macro evaluate_setting_priority(setting, page, section="", default_global_value="") %} -{#- Retrieve last ancestor to determine current section, if applicable -#} -{%- if page -%} +{%- if section -%} + {%- set current_section = section -%} +{%- elif page -%} + {#- Retrieve last ancestor to determine current section, if applicable -#} {%- set last_ancestor = page.ancestors | slice(start=-1) %} {%- set current_section = get_section(path=last_ancestor.0) %} {%- endif -%} diff --git a/templates/partials/header.html b/templates/partials/header.html index eb2eddd90..4b208adc1 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -74,7 +74,7 @@ {# Image for social media sharing #} - {%- set social_media_card = macros_settings::evaluate_setting_priority(setting="social_media_card", page=page | default(value=""), default_global_value="") -%} + {%- set social_media_card = macros_settings::evaluate_setting_priority(setting="social_media_card", page=page | default(value=""), section=section | default(value=""), default_global_value="") -%} {% if social_media_card %}