Skip to content

Instantly share code, notes, and snippets.

@thgbrb
Forked from jeremybise/baseof.html
Created July 6, 2021 00:23
Show Gist options
  • Save thgbrb/e7ada23029408b857767a99b5a7c911e to your computer and use it in GitHub Desktop.
Save thgbrb/e7ada23029408b857767a99b5a7c911e to your computer and use it in GitHub Desktop.

Revisions

  1. @jeremybise jeremybise revised this gist Jul 23, 2019. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions config.toml
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@
    [params]
    google_fonts = [
    ["Fira Code", "400, 700"],
    ["Open Sans", "400, 400i, 700, 700i"]
    ]

    google_fonts = [
    ["Fira Code", "400, 700"],
    ["Open Sans", "400, 400i, 700, 700i"]
    ]

    heading_font = "Fira Code"
    body_font = "Open Sans"
    heading_font = "Fira Code"
    body_font = "Open Sans"
  2. @jeremybise jeremybise revised this gist Apr 22, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions google-fonts.html
    Original file line number Diff line number Diff line change
    @@ -11,5 +11,6 @@
    {{ $url_part := (delimit $fonts "|") | safeHTMLAttr }}
    <link {{ printf "href=\"//fonts.googleapis.com/css?family=%s\"" $url_part | safeHTMLAttr }} rel="stylesheet">
    {{ else}}
    <!-- specify a default in case custom config not present -->
    <link href="//fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
    {{ end }}
  3. @jeremybise jeremybise renamed this gist Apr 22, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. @jeremybise jeremybise created this gist Apr 22, 2019.
    5 changes: 5 additions & 0 deletions baseof.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    <!-- Wherever your head tag is located, add the new partial -->

    <head>
    {{ partial "google-fonts" . }}
    </head>
    9 changes: 9 additions & 0 deletions config.foml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    [params]

    google_fonts = [
    ["Fira Code", "400, 700"],
    ["Open Sans", "400, 400i, 700, 700i"]
    ]

    heading_font = "Fira Code"
    body_font = "Open Sans"
    15 changes: 15 additions & 0 deletions google-fonts.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <!-- In your partials folder -->

    {{ if .Site.Params.google_fonts }}
    {{ $fonts := slice }}
    {{ range .Site.Params.google_fonts }}
    {{ $family := replace (index (.) 0) " " "+" }}
    {{ $weights := replace (index (.) 1) " " "" }}
    {{ $string := print $family ":" $weights }}
    {{ $fonts = $fonts | append $string }}
    {{ end }}
    {{ $url_part := (delimit $fonts "|") | safeHTMLAttr }}
    <link {{ printf "href=\"//fonts.googleapis.com/css?family=%s\"" $url_part | safeHTMLAttr }} rel="stylesheet">
    {{ else}}
    <link href="//fonts.googleapis.com/css?family=Roboto:300,400,700" rel="stylesheet">
    {{ end }}
    12 changes: 12 additions & 0 deletions stylesheet.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    /* Use the font config as variables in your SCSS */

    $font-heading: {{ $.Site.Params.heading_font | default "'Roboto', sans-serif" }};
    $font-body: {{ $.Site.Params.body_font | default "'Roboto', sans-serif" }};

    body {
    font-family: $font-body;
    }

    h1, h2, h3, h4, h5, h6 {
    font-family: $font-heading;
    }