Skip to content

Commit

Permalink
fix: google font url generator edge case
Browse files Browse the repository at this point in the history
we save font details saved in json object and then we generate url from it using jinja template.
there was a edge case where `;` was not being added at the end of normal weight.

incorrect https://fonts.googleapis.com/css2?family=JetBrains%20Mono:ital,wght@0,400;0,5001,400
correct https://fonts.googleapis.com/css2?family=JetBrains%20Mono:ital,wght@0,400;0,500;1,400
  • Loading branch information
maharshivpatel committed Apr 15, 2024
1 parent 263f3c0 commit d9d257b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro getFontStyles(fonts) -%}{%for key, value in fonts.items()%}{{key ~ ':ital,wght@'}}{%for index, size in enumerate(value.weight)%}{%if index > 0%};{%endif%}0,{{size}}{%endfor%}{%for index, size in enumerate(value.italic)%}{%if index > 0%};{%endif%}1,{{size}}{%endfor%}{% if not loop.last %}{{'&display=swap&family='}}{%endif%}{%endfor%}{%- endmacro %}
{% macro getFontStyles(fonts) -%}{%for key, value in fonts.items()%}{{key ~ ':ital,wght@'}}{%for index, size in enumerate(value.weight)%}{%if index > 0%};{%endif%}0,{{size}}{%endfor%}{%for index, size in enumerate(value.italic)%}{%if index > 0 or value.weight|length != 0 %};{%endif%}1,{{size}}{%endfor%}{% if not loop.last %}{{'&display=swap&family='}}{%endif%}{%endfor%}{%- endmacro %}

{% macro render_google_fonts(settings) %}
<link rel="preconnect" href="https://fonts.gstatic.com" />
Expand Down

0 comments on commit d9d257b

Please sign in to comment.