Здесь я хочу реализовать MathJax на своем веб-сайте. Я закодировал это в файле компонента:
export default ({ pathname, children }) => {
const post = posts.find(post => post.urlPath === pathname)
const title = post ? post.title : "(my website)"
return (
<div>
<Head>
<title>(my website) | {title}</title>
<style>{globalStyles}</style>
</Head>
<div className='contentContainer'>
<SiteTitle isHomepage={pathname === '/'} />
<Header />
{children}
</div>
</div>
)
}
Я добавил следующий код в тег <Head></Head>
:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML"></script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
},
CommonHTML: { matchFontHeight: false }
});
</script>
Мне нужно добавить конфигурацию tex2jax для удобства.
Я попытался запустить его. Однако, это не работает
[ error ] ./components/BlogLayout.js
SyntaxError: /home/website/components/BlogLayout.js: Unexpected token, expected "}" (72:15)
70 | <script type="text/x-mathjax-config">
71 | MathJax.Hub.Config({
> 72 | tex2jax: {
| ^
73 | inlineMath: [["\\(","\\)"] ],
74 | displayMath: [ ['$$','$$'], ["\\[","\\]"] ]
75 | },
\`\`\`
Как я могу запустить его?