feat: add support for social media cards (#130)

This commit is contained in:
Óscar
2023-09-06 13:38:52 +02:00
committed by GitHub
parent ab4b523f9c
commit d53b8470a6
77 changed files with 162 additions and 35 deletions

View File

@@ -1,4 +1,4 @@
{#
{#
Evaluates the priority of a particular setting across different scopes.
The priority is as follows: page > section > config.
@@ -9,10 +9,12 @@ Parameters:
- default_global_value: The setting's default value.
#}
{% macro evaluate_setting_priority(setting, page) %}
{% 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 -%}
@@ -20,17 +22,14 @@ Parameters:
{%- set priority_order = [
page.extra[setting] | default(value=""),
current_section.extra[setting] | default(value=""),
config.extra[setting] | default(value=default_global_value)
config.extra[setting] | default(value="")
] -%}
{%- set output = "false" -%}
{%- set output = default_global_value -%}
{%- for value in priority_order -%}
{%- if value == true -%}
{%- set_global output = "true" -%}
{%- break -%}
{%- elif value == false -%}
{%- set_global output = "false" -%}
{%- if value != "" -%}
{%- set_global output = value -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}