Skip to content

Commit

Permalink
feat: add rehype-katex-notranslate plugin for preventing symbols in…
Browse files Browse the repository at this point in the history
… formulas to be translated by browser translate-tools. (#1049)

* fix(format): format the codes

* fix(format): format the code

* feat: add rehype-katex-notranslate plugin to prevent symbol in formulas to be translated.

* update(dep): update `rehype-katex-notranslate` version
  • Loading branch information
PrinOrange authored Nov 3, 2024
1 parent 35ec4b2 commit 6289f94
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import rehypeSlug from 'rehype-slug'
import rehypeAutolinkHeadings from 'rehype-autolink-headings'
import rehypeKatex from 'rehype-katex'
import rehypeKatexNoTranslate from 'rehype-katex-notranslate'
import rehypeCitation from 'rehype-citation'
import rehypePrismPlus from 'rehype-prism-plus'
import rehypePresetMinify from 'rehype-preset-minify'
Expand Down Expand Up @@ -169,6 +170,7 @@ export default makeSource({
},
],
rehypeKatex,
rehypeKatexNoTranslate,
[rehypeCitation, { path: path.join(root, 'data') }],
[rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }],
rehypePresetMinify,
Expand Down
2 changes: 2 additions & 0 deletions data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,7 @@ Using the template? Support this effort by giving a star on GitHub, sharing your
[MIT](https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/LICENSE) © [Timothy Lin](https://www.timrlx.com)

[^1]: The previous version injects Preact into the production build. However, this is no longer possible as it does not support React Server Components. While overall bundle size has increased to about 85kB, most of the content can be pre-rendered on the server side, resulting in a low first contentful paint and time to interactive. Using React throughtout also leads to more consistent behavior with external libraries and components.

[^2]: This is different from Next.js App Directory layouts and are best thought of as reusable React containers.

[^3]: This takes advantage of Server Components by making it simple to specify the layout of choice in the markdown file and match against the `layouts` object which is then used to render the appropriate layout component.
2 changes: 1 addition & 1 deletion faq/customize-kbar-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function createSearchIndex(allBlogs) {
) {
writeFileSync(
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`,
JSON.stringify((sortPosts(allBlogs)))
JSON.stringify(sortPosts(allBlogs))
)
console.log('Local search index generated...')
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"rehype-autolink-headings": "^7.1.0",
"rehype-citation": "^2.0.0",
"rehype-katex": "^7.0.0",
"rehype-katex-notranslate": "^1.1.4",
"rehype-preset-minify": "7.0.0",
"rehype-prism-plus": "^2.0.0",
"rehype-slug": "^6.0.0",
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10009,6 +10009,16 @@ react@rc:
languageName: node
linkType: hard

"rehype-katex-notranslate@npm:^1.1.4":
version: 1.1.4
resolution: "rehype-katex-notranslate@npm:1.1.4"
dependencies:
unified: ^11.0.5
unist-util-visit: ^5.0.0
checksum: e43de356b695e0c7fa9d806f18c4447a976d0c7b9b11b7a70ac392b83566cc92622d3f73f408d3c923fcb159a5467d800db311816c436407b25208e16d27714d
languageName: node
linkType: hard

"rehype-katex@npm:^7.0.0":
version: 7.0.1
resolution: "rehype-katex@npm:7.0.1"
Expand Down Expand Up @@ -11347,6 +11357,7 @@ react@rc:
rehype-autolink-headings: ^7.1.0
rehype-citation: ^2.0.0
rehype-katex: ^7.0.0
rehype-katex-notranslate: ^1.1.4
rehype-preset-minify: 7.0.0
rehype-prism-plus: ^2.0.0
rehype-slug: ^6.0.0
Expand Down Expand Up @@ -11721,7 +11732,7 @@ react@rc:
languageName: node
linkType: hard

"unified@npm:^11.0.0, unified@npm:^11.0.4":
"unified@npm:^11.0.0, unified@npm:^11.0.4, unified@npm:^11.0.5":
version: 11.0.5
resolution: "unified@npm:11.0.5"
dependencies:
Expand Down

0 comments on commit 6289f94

Please sign in to comment.