Am I wrong to think this setup should result in my site making a network request for the relevant Google Font? Does the font loading feature only work for themes? I'm in development using localhost:8000.
/* src/utils/typography.js */
import Typography from 'typography';
import grandViewTheme from "typography-theme-grand-view";
grandViewTheme.bodyFontFamily = ['Alegreya', 'Sans-Serif'];
const typography = new Typography({
...grandViewTheme
});
export default typography;
/* gatsby-config.js */
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-typography`,
options: {
pathToConfigModule: `src/utils/typography.js`,
},
},
'gatsby-plugin-react-helmet',
'gatsby-plugin-sass',
],
};
You need to add the fonts to the googleFonts array to trigger a download.
Oh that's really simple... Thanks very much @KyleAMathews!
Might I suggest adding that nothing will be downloaded without this array to the TypographyJS Readme?
Here is an example for anyone who might be running into this
import Typography from "typography"
import fairyGateTheme from "typography-theme-fairy-gates"
fairyGateTheme.headerFontFamily = ['Open Sans', 'sans-serif']
fairyGateTheme.bodyFontFamily = ['Open Sans', 'sans-serif']
fairyGateTheme.googleFonts = [
{
name: 'Open Sans',
styles: [
'300',
'400',
'500',
'600',
'700'
],
}
]
const typography = new Typography(fairyGateTheme)
export default typography
Here is an example for anyone who might be running into this
import Typography from "typography" import fairyGateTheme from "typography-theme-fairy-gates" fairyGateTheme.headerFontFamily = ['Open Sans', 'sans-serif'] fairyGateTheme.bodyFontFamily = ['Open Sans', 'sans-serif'] fairyGateTheme.googleFonts = [ { name: 'Open Sans', styles: [ '300', '400', '500', '600', '700' ], } ] const typography = new Typography(fairyGateTheme) export default typography
thank you dude. helped me a lot, thank you.
Most helpful comment
Here is an example for anyone who might be running into this