我是 Gatsby 的新手(以及一般的前端)。我正在尝试根据博客主题https://www.gatsbyjs.org/packages/gatsby-theme-blog/将 katex 插件https://www.gatsbyjs.org/packages/gatsby-remark-katex/添加到我的项目中但它不起作用。
我所做的如下:从gatsby-theme-blog
$ gatsby new my-themed-blog https://github.com/gatsbyjs/gatsby-starter-blog-theme
$ cd my-themed-blog
在项目的顶部,安装gatsby-remark-katex
插件,
$ npm install --save gatsby-transformer-remark gatsby-remark-katex katex
在顶层添加配置gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-theme-blog`,
options: {},
},
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-katex`,
options: {
// Add any KaTeX options from https://github.com/KaTeX/KaTeX/blob/master/docs/options.md here
strict: `ignore`
}
}
],
},
},
],
// Customize your site metadata:
siteMetadata: {
// ... cutting the following
},
}
并将顶层的css导入gatsby-browser.js
为
import "katex/dist/katex.min.css"
content/posts
如果我把一些降价文档放在下面
---
title: Hello World (example)
date: 2019-12-18
---
math $x + y = \epsilon$.
网页显示就像
Hello World (example)
December 18, 2019
math $x + y = \epsilon$.
我是为普通的 gatsby 项目以及博客启动器https://www.gatsbyjs.org/starters/gatsbyjs/gatsby-starter-blog/做的, 比如从
$ gatsby new gatsby-starter-blog https://github.com/gatsbyjs/gatsby-starter-blog
编辑gatsby-config.js
喜欢
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-images`,
options: {
maxWidth: 590,
},
},
{
resolve: `gatsby-remark-responsive-iframe`,
options: {
wrapperStyle: `margin-bottom: 1.0725rem`,
},
},
`gatsby-remark-prismjs`,
`gatsby-remark-copy-linked-files`,
`gatsby-remark-smartypants`,
{
resolve: `gatsby-remark-katex`,
options: {
// Add any KaTeX options from https://github.com/KaTeX/KaTeX/blob/master/docs/options.md here
strict: `ignore`
}
}
],
},
},
和gatsby-browser.js
// custom typefaces
import "typeface-montserrat"
import "typeface-merriweather"
import "katex/dist/katex.min.css"
它正在工作。
如何使用 blog-theme 之类的主题将 katex 插件添加到项目中?node_modules
我应该以某种方式将它添加到主题目录中吗?
谢谢!