+
-
+
© {new Date().getFullYear()} {siteConfig.copyright} All
rights reserved.
diff --git a/src/lib/rehypePlugin.ts b/src/lib/rehypePlugin.ts
new file mode 100644
index 0000000..9ae5951
--- /dev/null
+++ b/src/lib/rehypePlugin.ts
@@ -0,0 +1,28 @@
+import { visit } from 'unist-util-visit'
+import { Plugin } from 'unified'
+import { Node, Element } from 'hast'
+
+export const addClassToTitles: Plugin = () => {
+ return (tree: Node) => {
+ visit(tree, 'element', (node: Element) => {
+ if (
+ node.tagName === 'h1' ||
+ node.tagName === 'h2' ||
+ node.tagName === 'h3' ||
+ node.tagName === 'h4' ||
+ node.tagName === 'h5' ||
+ node.tagName === 'h6'
+ ) {
+ node.properties = node.properties || {}
+ const existingClasses = Array.isArray(node.properties.className)
+ ? node.properties.className
+ : []
+
+ node.properties.className = [
+ 'font-extrabold tracking-tighter break-word',
+ ...existingClasses,
+ ]
+ }
+ })
+ }
+}
diff --git a/src/pages/[locale]/doc/[...slug].tsx b/src/pages/[locale]/doc/[...slug].tsx
index b2e52cc..be90f1b 100644
--- a/src/pages/[locale]/doc/[...slug].tsx
+++ b/src/pages/[locale]/doc/[...slug].tsx
@@ -20,6 +20,7 @@ import { getI18nProps } from '@/lib/getStatic'
import DocContents from '@/components/articles/doc/DocContents'
import youtubeTransformer from '@/lib/youtubeTransformer'
import embedder from '@remark-embedder/core'
+import { addClassToTitles } from '@/lib/rehypePlugin'
const articleDirName = 'doc'
@@ -75,6 +76,7 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
})
.use(rehypeCodeTitles)
.use(rehypeHighlight)
+ .use(addClassToTitles)
.use(rehypeStringify)
.process(article.content as string)
diff --git a/src/pages/[locale]/legal/[...slug].tsx b/src/pages/[locale]/legal/[...slug].tsx
index 19c2e2e..01cadd9 100644
--- a/src/pages/[locale]/legal/[...slug].tsx
+++ b/src/pages/[locale]/legal/[...slug].tsx
@@ -18,6 +18,7 @@ import { getAllArticles, getArticleBySlug } from '@/utils/article'
import DefaultLayout from '@/layouts/default/DefaultLayout'
import { getI18nProps } from '@/lib/getStatic'
import LegalContents from '@/components/articles/legal/LegalContents'
+import { addClassToTitles } from '@/lib/rehypePlugin'
const articleDirName = 'legal'
@@ -70,6 +71,7 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
rel: ['noopener noreferrer'],
})
.use(rehypeHighlight)
+ .use(addClassToTitles)
.use(rehypeStringify)
.process(article.content as string)
diff --git a/src/pages/[locale]/news/[...slug].tsx b/src/pages/[locale]/news/[...slug].tsx
index bf6df58..c307b12 100644
--- a/src/pages/[locale]/news/[...slug].tsx
+++ b/src/pages/[locale]/news/[...slug].tsx
@@ -22,6 +22,7 @@ import NewsContents from '@/components/articles/news/NewsContents'
import NewsPageIndex from '@/components/articles/news/NewsPageIndex'
import youtubeTransformer from '@/lib/youtubeTransformer'
import embedder from '@remark-embedder/core'
+import { addClassToTitles } from '@/lib/rehypePlugin'
const articleDirName = 'news'
@@ -82,6 +83,7 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
})
.use(rehypeCodeTitles)
.use(rehypeHighlight)
+ .use(addClassToTitles)
.use(rehypeStringify)
.process(article.content as string)
diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx
index bcd4f7e..6ec9fa9 100644
--- a/src/pages/_document.tsx
+++ b/src/pages/_document.tsx
@@ -14,7 +14,7 @@ export default class MyDocument extends Document {
crossOrigin="anonymous"
/>