gatsby and typefaces

Created on 19 Dec 2017  路  4Comments  路  Source: gatsbyjs/gatsby

I am trying to use gatsby with typefaces.
After installing the fonts. I did an import from src/layouts/index.js as done in gatsbygram

import 'typeface-quattrocento-sans';
import 'typeface-work-sans';

When I do a build, and check the index.html I am still seeing

<link href="//fonts.googleapis.com/css?family=Work+Sans:600|Quattrocento+Sans:400,400i,700" rel="stylesheet" type="text/css"/>

But, this is what I am trying to avoid. Is there something I need to do, so this is not included in the index.html file everytime?

question or discussion

Most helpful comment

Nice. I just deleted the googleFonts property from the fairyGates theme and it worked like charm.

import fairyGatesTheme from 'typography-theme-fairy-gates';

delete fairyGatesTheme.googleFonts;
const typography = new Typography(fairyGatesTheme);

All 4 comments

Hi,

this is a task that I also have to tackle soon - the starter templates come with the typography plugin and the Gatsby website also has this typography.js file in utilities with overwrites for default styles.

I am curious - are you using one of the templates or just the vanilla gatsby-cli output?

@mpolinowski I had picked up one of the templates. But then I changed it quiet a bit since then.
The template did not bring in the typography plugin as far as I can remember, I added that along with the typography.js file in utilities as shown in the gatsby tutorial.

You need to remove googleFonts from the Typography.js theme in order to prevent the Google Fonts link from being added. gatsby-plugin-typography auto adds the link to google fonts if it sees them defined on the typography.js object.

Nice. I just deleted the googleFonts property from the fairyGates theme and it worked like charm.

import fairyGatesTheme from 'typography-theme-fairy-gates';

delete fairyGatesTheme.googleFonts;
const typography = new Typography(fairyGatesTheme);

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rossPatton picture rossPatton  路  3Comments

brandonmp picture brandonmp  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

ferMartz picture ferMartz  路  3Comments