自从安装typography.js以来,我得到了这个错误:
error There was an error compiling the html.js component for the development server.
14 | // Create family + styles string
15 | var fontsStr = '';
> 16 | if (props.typography.options.googleFonts) {
| ^
17 | var fonts = props.typography.options.googleFonts.map(function (font) {
18 | var str = '';
19 | str += font.name.split(' ').join('+');
WebpackError: Cannot read property 'googleFonts' of undefined
- GoogleFont.js:16 GoogleFont
~/react-typography/dist/GoogleFont.js:16:1
...我不确定这是什么意思,也不知道如何修复它。我正在使用Gatsby.js默认的初学者包
typography.js这样做:
import Typography from "typography";
const typography = new Typography({
baseFontSize: "18px",
baseLineHeight: 1.45,
headerFontFamily: [
"Avenir Next",
"Helvetica Neue",
"Segoe UI",
"Helvetica",
"Arial",
"sans-serif",
],
bodyFontFamily: ["Georgia", "serif"],
});和gatsby-config.js:
module.exports = {
siteMetadata: {
title: `Gatsby Default Starter`
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-styled-components`,
{
resolve: `gatsby-plugin-typography`,
options: {
pathToConfigModule: 'src/utilities/typography.js'
},
},
]
};https://stackoverflow.com/questions/51356419
复制相似问题