Skip to content

Commit

Permalink
✨ feat: allow social media cards on sections
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Sep 3, 2023
1 parent 1584e1a commit e965aa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions templates/macros/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down

0 comments on commit e965aa4

Please sign in to comment.