feat: move font config to global data cascade

This commit is contained in:
Devin Haska 2024-02-01 15:03:33 -08:00
parent ad435a16db
commit f9926b3bac
14 changed files with 223 additions and 43 deletions

View 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 %}

View 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 %}
}