Skip to content

Commit

Permalink
PLANET-6080 Add fonts in HTML head for campaigns
Browse files Browse the repository at this point in the history
* Also add display=swap for better loading.
  • Loading branch information
Inwerpsel committed Apr 20, 2021
1 parent 8c019ee commit 2145df2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions single-campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ static function ( $page ) {
$context['custom_styles'] = $custom_styles;
$context['css_vars'] = PostCampaign::css_vars( $campaign_meta );

if ( $theme_name && 'default' !== $theme_name ) {
$context['custom_font_families'] = [
'Montserrat:300,400,500,600,700,800',
'Kanit:400,500,600,800',
'Open+Sans:400,500,600,800',
'Anton:400,500,600,800',
'Amiko:400,500,600,800',
];
}

// Social footer link overrides.
$context['social_overrides'] = [];

Expand Down
5 changes: 5 additions & 0 deletions templates/head/google_fonts.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap&subset=latin-ext"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,400i,700&display=swap&subset=latin-ext"/>
{% for font_family in custom_font_families %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family={{ font_family }}&display=swap"/>
{% endfor %}
3 changes: 1 addition & 2 deletions templates/html-header.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
<link rel="shortcut icon" type="image/ico" href="{{ theme.uri }}/favicon.ico"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900&display=swap&subset=latin-ext"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,400i,700&display=swap&subset=latin-ext"/>
{% include 'head/google_fonts.twig' %}

{% if hreflang %}
<!-- hreflang metadata -->
Expand Down

0 comments on commit 2145df2

Please sign in to comment.