blog/_includes/functions/get_value.html
jeffreytse 245fe2a047 fix: get value from site config incorrectly
When the value is stored in a dictionary and the value isn't
presented in front matter, the get_value function can not get
value from the site config instead.
2021-06-25 14:13:00 +08:00

42 lines
1,009 B
HTML

{%- if include.params.name -%}
{%- assign name = include.params.name -%}
{%- endif -%}
{%- assign return = nil -%}
{%- assign keys = name | split:'.' -%}
{%- assign name = keys.first -%}
{%- assign keys = keys | shift -%}
{%- for step in (1..7) -%}
{%- case step -%}
{%- when 1 -%}
{%- assign return = page[name] -%}
{%- when 2 -%}
{%- assign return = site[name] -%}
{%- when 3 -%}
{%- assign return = site.data[name] -%}
{%- when 4 -%}
{%- assign return = site.defaults[page.layout][name] -%}
{%- when 5 -%}
{%- assign return = site.data.defaults[page.layout][name] -%}
{%- when 6 -%}
{%- assign return = layout[name] -%}
{%- else -%}
{%- assign return = include.params.default -%}
{%- endcase -%}
{%- for key in keys -%}
{%- assign return = return[key] -%}
{%- if return == nil -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- if return != nil -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}