blog/_includes/functions/get_value.html
2021-06-17 18:57:37 +08:00

32 lines
988 B
HTML

{%- if include.params.name -%}
{%- assign name = include.params.name -%}
{%- endif -%}
{%- assign keys = name | split:'.' -%}
{%- assign name = keys.first -%}
{%- if page[name] != nil -%}
{%- assign return = page[name] -%}
{%- elsif site[name] != nil -%}
{%- assign return = site[name] -%}
{%- elsif site.data[name] != nil -%}
{%- assign return = site.data[name] -%}
{%- elsif site.defaults[page.layout][name] != nil -%}
{%- assign return = site.defaults[page.layout][name] -%}
{%- elsif site.data.defaults[page.layout][name] != nil -%}
{%- assign return = site.data.defaults[page.layout][name] -%}
{%- elsif layout[name] != nil -%}
{%- assign return = layout[name] -%}
{%- else -%}
{%- assign return = include.params.default -%}
{%- endif -%}
{%- assign keys = keys | shift -%}
{%- for key in keys -%}
{%- assign return = return[key] -%}
{%- if return == nil -%}
{%- assign return = include.params.default -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}