From 6289f94e8737ce225071769472f7e8a3631fdc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E5=88=80=E9=B1=BC=E4=B9=8B=E6=84=BF?= Date: Sun, 3 Nov 2024 17:01:35 +0800 Subject: [PATCH] feat: add `rehype-katex-notranslate` plugin for preventing symbols in 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 --- contentlayer.config.ts | 2 ++ ...release-of-tailwind-nextjs-starter-blog-v2.0.mdx | 2 ++ faq/customize-kbar-search.md | 2 +- package.json | 1 + yarn.lock | 13 ++++++++++++- 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/contentlayer.config.ts b/contentlayer.config.ts index 63e51dd..312780e 100644 --- a/contentlayer.config.ts +++ b/contentlayer.config.ts @@ -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' @@ -169,6 +170,7 @@ export default makeSource({ }, ], rehypeKatex, + rehypeKatexNoTranslate, [rehypeCitation, { path: path.join(root, 'data') }], [rehypePrismPlus, { defaultLanguage: 'js', ignoreMissing: true }], rehypePresetMinify, diff --git a/data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx b/data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx index 0141dd9..37afcbb 100644 --- a/data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx +++ b/data/blog/release-of-tailwind-nextjs-starter-blog-v2.0.mdx @@ -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. diff --git a/faq/customize-kbar-search.md b/faq/customize-kbar-search.md index 6e3995e..dac8bc7 100644 --- a/faq/customize-kbar-search.md +++ b/faq/customize-kbar-search.md @@ -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...') } diff --git a/package.json b/package.json index 13cdad0..e61948d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 749ad5d..a045903 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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 @@ -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: