Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self host fonts #21

Merged
merged 3 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions gatsby-node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
exports.modifyWebpackConfig = function(config, stage) {
config.removeLoader('woff')
config.loader('woff', {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file',
query: {
name: `static/[name].[hash:8].[ext]`,
},
})

return config
}
17 changes: 8 additions & 9 deletions html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import React from 'react'
import Helmet from "react-helmet"

import { prefixLink } from 'gatsby-helpers'
import { TypographyStyle, GoogleFont } from 'react-typography'
import { TypographyStyle } from 'react-typography'
import typography from './utils/typography'
import styleSheet from 'styled-components/lib/models/StyleSheet'



const BUILD_TIME = new Date().getTime()

module.exports = React.createClass({
Expand All @@ -29,23 +27,24 @@ module.exports = React.createClass({
return (
<html lang="en">
<head>
<link rel="preload" href="/static/work-sans-latin-500.3c4e10fc.woff2" as="font" type="font/woff2" crossOrigin />
<link rel="preload" href="/static/space-mono-latin-700.eadcd2d5.woff2" as="font" type="font/woff2" crossOrigin />
<meta charSet="utf-8" />
<meta httpEquiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link rel="apple-touch-icon" sizes="180x180" href={require('assets/apple-touch-icon.png')}/>
<link rel="icon" type="image/png" href={require('assets/favicon-32x32.png')} sizes="32x32"/>
<link rel="icon" type="image/png" href={require('assets/favicon-16x16.png')} sizes="16x16"/>
<link rel="manifest" href={require('assets/manifest.json')}/>
<link rel="mask-icon" href={require('assets/safari-pinned-tab.svg')} color="#5bbad5"/>
<link rel="apple-touch-icon" sizes="180x180" href={require('file-loader!assets/apple-touch-icon.png')}/>
<link rel="icon" type="image/png" href={require('file-loader!assets/favicon-32x32.png')} sizes="32x32"/>
<link rel="icon" type="image/png" href={require('file-loader!assets/favicon-16x16.png')} sizes="16x16"/>
<link rel="manifest" href={require('file-loader!assets/manifest.json')}/>
<link rel="mask-icon" href={require('file-loader!assets/safari-pinned-tab.svg')} color="#5bbad5"/>
<meta name="theme-color" content="#ffffff"/>

{head.title.toComponent()}
{head.meta.toComponent()}
<TypographyStyle typography={typography} />
<GoogleFont typography={typography} />
{css}
<style>
{styles}
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"react-typography": "^0.14.0",
"styled-components": "^1.0.11",
"toml-js": "0.0.8",
"typeface-poppins": "^0.0.8",
"typeface-space-mono": "^0.0.6",
"typeface-work-sans": "^0.0.8",
"typography": "^0.14.0",
"typography-plugin-code": "^0.14.0"
},
Expand Down
5 changes: 5 additions & 0 deletions pages/_template.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import Headroom from 'react-headroom'
import '../css/markdown-styles'
import '../css/styles'

// Add our typefaces.
import 'typeface-poppins'
import 'typeface-work-sans'
import 'typeface-space-mono'

import { rhythm } from '../utils/typography'
import {
Header,
Expand Down
23 changes: 0 additions & 23 deletions utils/typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,6 @@ import { GoogleFont } from 'react-typography'
import CodePlugin from 'typography-plugin-code'

const options = {
googleFonts: [
{
name: 'Work Sans',
styles: [
'400',
'500',
],
},
{
name: 'Space Mono',
styles: [
'400',
'700',
],
},
{
name: 'Poppins',
styles: [
'400',
'600',
],
}
],
headerFontFamily: ['Work Sans', 'sans-serif'],
bodyFontFamily: ['Work Sans', 'sans-serif'],
baseFontSize: '19px',
Expand Down
Loading