feat: allow social media cards on sections

This commit is contained in:
welpo 2023-09-03 22:07:45 +02:00
parent 1584e1ab4b
commit e965aa45b3
No known key found for this signature in database
GPG key ID: A2F978CF4EC1F5A6
2 changed files with 6 additions and 4 deletions

View file

@ -9,10 +9,12 @@ Parameters:
- 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 -%}

View file

@ -74,7 +74,7 @@
<meta property="og:type" content="article" />
{# 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 %}
<meta property="og:image" content="{{ get_url(path=social_media_card) }}" />
<meta name="twitter:card" content="summary_large_image" />