✨ feat: add support for social media cards (#130)
This commit is contained in:
@@ -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 -%}
|
||||
|
Reference in New Issue
Block a user