feat: move font config to global data cascade
This commit is contained in:
parent
ad435a16db
commit
f9926b3bac
14 changed files with 223 additions and 43 deletions
19
src/_includes/css/fontFace.njk
Normal file
19
src/_includes/css/fontFace.njk
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% set allFonts = fonts | values %}
|
||||
{% for font in allFonts %}
|
||||
{% set weights = font.weights | values %}
|
||||
{% for fontEntry in weights %}
|
||||
{% if fontEntry.url %}
|
||||
{% set family = font.family %}
|
||||
{% set localName = font.family %}
|
||||
{% set postScriptName = [font.family, fontEntry.variant] | join("-") | replace(" ", "") %}
|
||||
@font-face {
|
||||
font-family: {{ family }};
|
||||
font-style: {{ fontEntry.style }};
|
||||
font-weight: {{ fontEntry.weight }};
|
||||
{% if fontEntry.display %}font-display: {{ fontEntry.display }};{% endif %}
|
||||
src: local("{{ localName }}"), local("{{ postScriptName }}"), url("{{ fontEntry.url }}") format("{{ fontEntry.format }}")
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
19
src/_includes/css/fontVariables.njk
Normal file
19
src/_includes/css/fontVariables.njk
Normal file
|
@ -0,0 +1,19 @@
|
|||
{% set allFonts = fonts | entries %}
|
||||
|
||||
html {
|
||||
{% for font in allFonts %}
|
||||
{% set fontType = font | first %}
|
||||
{% set fontConfig = font | last %}
|
||||
{% set fallbackFonts = fontConfig.fallbacks | join(", ") %}
|
||||
--font-family-{{ fontType }}: {{ fontConfig.family }}, {{ fallbackFonts }};
|
||||
{% set weights = fontConfig.weights | entries %}
|
||||
{% for weight in weights %}
|
||||
{% set weightName = weight | first %}
|
||||
{% set weightConfig = weight | last %}
|
||||
{% if weightConfig.style != "italic" %}
|
||||
--font-weight-{{ fontType }}-{{ weightName | lower }}: {{ weightConfig.weight }};
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue