diff --git a/astro.config.mts b/astro.config.mts
index 3ab3327..5b23eda 100644
--- a/astro.config.mts
+++ b/astro.config.mts
@@ -1,16 +1,19 @@
-import { defineConfig } from "astro/config"
-import { SITE_URL } from "./src/consts"
-import vue from "@astrojs/vue"
-import tailwind from "@astrojs/tailwind"
-import react from "@astrojs/react"
-import { handleLocalCoverPlugin } from "./src/plugins/cover"
-import { themePipeline } from "./src/plugins/theme"
+import { defineConfig } from "astro/config";
+import { SITE_URL } from "./src/consts";
+import vue from "@astrojs/vue";
+import tailwind from "@astrojs/tailwind";
+import react from "@astrojs/react";
+import { handleLocalCoverPlugin } from "./src/plugins/cover";
+import { themePipeline } from "./src/plugins/theme";
+import remarkToc from "remark-toc";
+import rehypeSlug from "rehype-slug";
// https://astro.build/config
export default defineConfig({
site: SITE_URL,
markdown: {
- rehypePlugins: [handleLocalCoverPlugin, ...themePipeline],
+ remarkPlugins: [[remarkToc, { heading: "目录", tight: true }]],
+ rehypePlugins: [rehypeSlug, handleLocalCoverPlugin, ...themePipeline],
syntaxHighlight: "shiki",
shikiConfig: {
themes: {
@@ -33,16 +36,13 @@ export default defineConfig({
"/active": {
target: "https://active.nbtca.space",
changeOrigin: true,
- rewrite: path => path.replace(/^\/active/, ""),
+ rewrite: (path) => path.replace(/^\/active/, ""),
},
"/saturday": {
target: "http://localhost:4000",
- rewrite: path => path.replace(/^\/saturday/, ""),
+ rewrite: (path) => path.replace(/^\/saturday/, ""),
},
},
},
- // optimizeDeps: {
- // exclude: ["dayjs"],
- // },
},
-})
+});
diff --git a/package.json b/package.json
index 4ca2246..60b6338 100644
--- a/package.json
+++ b/package.json
@@ -38,6 +38,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rehype": "^13.0.2",
+ "rehype-slug": "^6.0.0",
+ "remark-toc": "^9.0.0",
"sharp": "^0.33.5",
"tailwindcss": "^3.4.17",
"unist-util-visit": "^5.0.0",
@@ -49,6 +51,7 @@
"@cspell/eslint-plugin": "^8.19.2",
"@eslint/js": "^9.25.1",
"@hey-api/openapi-ts": "^0.53.12",
+ "@tailwindcss/typography": "^0.5.16",
"@types/eslint__js": "^8.42.3",
"@types/md5": "^2.3.5",
"@types/qrcode": "^1.5.5",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 05b8bc2..e26975f 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -80,6 +80,12 @@ importers:
rehype:
specifier: ^13.0.2
version: 13.0.2
+ rehype-slug:
+ specifier: ^6.0.0
+ version: 6.0.0
+ remark-toc:
+ specifier: ^9.0.0
+ version: 9.0.0
sharp:
specifier: ^0.33.5
version: 0.33.5
@@ -108,6 +114,9 @@ importers:
'@hey-api/openapi-ts':
specifier: ^0.53.12
version: 0.53.12(magicast@0.3.5)(typescript@5.8.3)
+ '@tailwindcss/typography':
+ specifier: ^0.5.16
+ version: 0.5.16(tailwindcss@3.4.17)
'@types/eslint__js':
specifier: ^8.42.3
version: 8.42.3
@@ -2371,6 +2380,11 @@ packages:
'@swc/helpers@0.5.17':
resolution: {integrity: sha512-5IKx/Y13RsYd+sauPb2x+U/xZikHjolzfuDgTAl/Tdf3Q8rslRvC19NKDLgAJQ6wsqADk10ntlv08nPFw/gO/A==}
+ '@tailwindcss/typography@0.5.16':
+ resolution: {integrity: sha512-0wDLwCVF5V3x3b1SGXPCDcdsbDHMBe+lkFzBRaHeLvNi+nrrnZ1lA18u+OTWO8iSWU2GxUOCvlXtDuqftc1oiA==}
+ peerDependencies:
+ tailwindcss: '>=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1'
+
'@tanstack/react-virtual@3.11.3':
resolution: {integrity: sha512-vCU+OTylXN3hdC8RKg68tPlBPjjxtzon7Ys46MgrSLE+JhSjSTPvoQifV6DQJeJmA8Q3KT6CphJbejupx85vFw==}
peerDependencies:
@@ -2462,6 +2476,9 @@ packages:
'@types/react@18.3.23':
resolution: {integrity: sha512-/LDXMQh55EzZQ0uVAZmKKhfENivEvWz6E+EYzh+/MCjMhNsotd+ZHhBGIjFDTi6+fz0OhQQQLbTgdQIxxCsC0w==}
+ '@types/ungap__structured-clone@1.2.0':
+ resolution: {integrity: sha512-ZoaihZNLeZSxESbk9PUAPZOlSpcKx81I1+4emtULDVmBLkYutTcMlCj2K9VNlf9EWODxdO6gkAqEaLorXwZQVA==}
+
'@types/unist@3.0.3':
resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==}
@@ -2877,11 +2894,11 @@ packages:
resolution: {integrity: sha512-F3PH5k5juxom4xktynS7MoFY+NUWH5LC4CnH11YB8NPew+HLpmBLCybSAEyb2F+4pRXhuhWqFesoQd6DAyc2hw==}
engines: {node: '>=18'}
- brace-expansion@1.1.11:
- resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==}
+ brace-expansion@1.1.12:
+ resolution: {integrity: sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==}
- brace-expansion@2.0.1:
- resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==}
+ brace-expansion@2.0.2:
+ resolution: {integrity: sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==}
braces@3.0.3:
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
@@ -3752,6 +3769,9 @@ packages:
hast-util-from-parse5@8.0.3:
resolution: {integrity: sha512-3kxEVkEKt0zvcZ3hCRYI8rqrgwtlIOFMWkbclACvjlDw8Li9S2hk/d51OI0nr/gIpdMHNepwgOKqZ/sy0Clpyg==}
+ hast-util-heading-rank@3.0.0:
+ resolution: {integrity: sha512-EJKb8oMUXVHcWZTDepnr+WNbfnXKFNf9duMesmr4S8SXTJBJ9M4Yok08pu9vxdJwdlGRhVumk9mEhkEvKGifwA==}
+
hast-util-is-element@3.0.0:
resolution: {integrity: sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==}
@@ -3767,6 +3787,9 @@ packages:
hast-util-to-parse5@8.0.0:
resolution: {integrity: sha512-3KKrV5ZVI8if87DVSi1vDeByYrkGzg4mEfeu4alwgmmIeARiBLKCZS2uw5Gb6nU9x9Yufyj3iudm6i7nl52PFw==}
+ hast-util-to-string@3.0.1:
+ resolution: {integrity: sha512-XelQVTDWvqcl3axRfI0xSeoVKzyIFPwsAGSLIsKdJKQMXDYJS4WYrBNF/8J7RdhIcFI2BOHgAifggsvsxp/3+A==}
+
hast-util-to-text@4.0.2:
resolution: {integrity: sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==}
@@ -4139,6 +4162,12 @@ packages:
resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==}
engines: {node: '>=10'}
+ lodash.castarray@4.4.0:
+ resolution: {integrity: sha512-aVx8ztPv7/2ULbArGJ2Y42bG1mEQ5mGjpdvrbJcJFU3TbYybe+QlLS4pst9zV52ymy2in1KpFPiZnAOATxD4+Q==}
+
+ lodash.isplainobject@4.0.6:
+ resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==}
+
lodash.merge@4.6.2:
resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
@@ -4222,6 +4251,9 @@ packages:
mdast-util-to-string@4.0.0:
resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==}
+ mdast-util-toc@7.1.0:
+ resolution: {integrity: sha512-2TVKotOQzqdY7THOdn2gGzS9d1Sdd66bvxUyw3aNpWfcPXCLYSJCCgfPy30sEtuzkDraJgqF35dzgmz6xlvH/w==}
+
merge-stream@2.0.0:
resolution: {integrity: sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==}
@@ -4680,6 +4712,10 @@ packages:
peerDependencies:
postcss: ^8.2.14
+ postcss-selector-parser@6.0.10:
+ resolution: {integrity: sha512-IQ7TZdoaqbT+LCpShg46jnZVlhWD2w6iQYAcYXfHARZ7X1t/UGhhceQDs5X0cGqKvYlHNOuv7Oa1xmb0oQuA3w==}
+ engines: {node: '>=4'}
+
postcss-selector-parser@6.1.2:
resolution: {integrity: sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==}
engines: {node: '>=4'}
@@ -4799,6 +4835,9 @@ packages:
rehype-raw@7.0.0:
resolution: {integrity: sha512-/aE8hCfKlQeA8LmyeyQvQF3eBiLRGNlfBJEvWH7ivp9sBqs7TNqBL5X3v157rM4IFETqDnIOO+z5M/biZbo9Ww==}
+ rehype-slug@6.0.0:
+ resolution: {integrity: sha512-lWyvf/jwu+oS5+hL5eClVd3hNdmwM1kAC0BUvEGD19pajQMIzcNUd/k9GsfQ+FfECvX+JE+e9/btsKH0EjJT6A==}
+
rehype-stringify@10.0.1:
resolution: {integrity: sha512-k9ecfXHmIPuFVI61B9DeLPN0qFHfawM6RsuX48hoqlaKSF61RskNjSm1lI8PhBEM0MRdLxVVm4WmTqJQccH9mA==}
@@ -4821,6 +4860,9 @@ packages:
remark-stringify@11.0.0:
resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==}
+ remark-toc@9.0.0:
+ resolution: {integrity: sha512-KJ9txbo33GjDAV1baHFze7ij4G8c7SGYoY8Kzsm2gzFpbhL/bSoVpMMzGa3vrNDSWASNd/3ppAqL7cP2zD6JIA==}
+
repeat-string@1.6.1:
resolution: {integrity: sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==}
engines: {node: '>=0.10'}
@@ -8772,6 +8814,14 @@ snapshots:
dependencies:
tslib: 2.8.1
+ '@tailwindcss/typography@0.5.16(tailwindcss@3.4.17)':
+ dependencies:
+ lodash.castarray: 4.4.0
+ lodash.isplainobject: 4.0.6
+ lodash.merge: 4.6.2
+ postcss-selector-parser: 6.0.10
+ tailwindcss: 3.4.17
+
'@tanstack/react-virtual@3.11.3(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
dependencies:
'@tanstack/virtual-core': 3.11.3
@@ -8875,6 +8925,8 @@ snapshots:
'@types/prop-types': 15.7.14
csstype: 3.1.3
+ '@types/ungap__structured-clone@1.2.0': {}
+
'@types/unist@3.0.3': {}
'@types/uuid@10.0.0': {}
@@ -9463,12 +9515,12 @@ snapshots:
widest-line: 5.0.0
wrap-ansi: 9.0.0
- brace-expansion@1.1.11:
+ brace-expansion@1.1.12:
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
- brace-expansion@2.0.1:
+ brace-expansion@2.0.2:
dependencies:
balanced-match: 1.0.2
@@ -10475,6 +10527,10 @@ snapshots:
vfile-location: 5.0.3
web-namespaces: 2.0.1
+ hast-util-heading-rank@3.0.0:
+ dependencies:
+ '@types/hast': 3.0.4
+
hast-util-is-element@3.0.0:
dependencies:
'@types/hast': 3.0.4
@@ -10523,6 +10579,10 @@ snapshots:
web-namespaces: 2.0.1
zwitch: 2.0.4
+ hast-util-to-string@3.0.1:
+ dependencies:
+ '@types/hast': 3.0.4
+
hast-util-to-text@4.0.2:
dependencies:
'@types/hast': 3.0.4
@@ -10871,6 +10931,10 @@ snapshots:
dependencies:
p-locate: 5.0.0
+ lodash.castarray@4.4.0: {}
+
+ lodash.isplainobject@4.0.6: {}
+
lodash.merge@4.6.2: {}
log-symbols@6.0.0:
@@ -11040,6 +11104,16 @@ snapshots:
dependencies:
'@types/mdast': 4.0.4
+ mdast-util-toc@7.1.0:
+ dependencies:
+ '@types/mdast': 4.0.4
+ '@types/ungap__structured-clone': 1.2.0
+ '@ungap/structured-clone': 1.3.0
+ github-slugger: 2.0.0
+ mdast-util-to-string: 4.0.0
+ unist-util-is: 6.0.0
+ unist-util-visit: 5.0.0
+
merge-stream@2.0.0: {}
merge2@1.4.1: {}
@@ -11246,15 +11320,15 @@ snapshots:
minimatch@3.1.2:
dependencies:
- brace-expansion: 1.1.11
+ brace-expansion: 1.1.12
minimatch@5.1.6:
dependencies:
- brace-expansion: 2.0.1
+ brace-expansion: 2.0.2
minimatch@9.0.5:
dependencies:
- brace-expansion: 2.0.1
+ brace-expansion: 2.0.2
minimist@1.2.8: {}
@@ -11582,6 +11656,11 @@ snapshots:
postcss: 8.5.3
postcss-selector-parser: 6.1.2
+ postcss-selector-parser@6.0.10:
+ dependencies:
+ cssesc: 3.0.0
+ util-deprecate: 1.0.2
+
postcss-selector-parser@6.1.2:
dependencies:
cssesc: 3.0.0
@@ -11718,6 +11797,14 @@ snapshots:
hast-util-raw: 9.1.0
vfile: 6.0.3
+ rehype-slug@6.0.0:
+ dependencies:
+ '@types/hast': 3.0.4
+ github-slugger: 2.0.0
+ hast-util-heading-rank: 3.0.0
+ hast-util-to-string: 3.0.1
+ unist-util-visit: 5.0.0
+
rehype-stringify@10.0.1:
dependencies:
'@types/hast': 3.0.4
@@ -11772,6 +11859,11 @@ snapshots:
mdast-util-to-markdown: 2.1.2
unified: 11.0.5
+ remark-toc@9.0.0:
+ dependencies:
+ '@types/mdast': 4.0.4
+ mdast-util-toc: 7.1.0
+
repeat-string@1.6.1: {}
require-directory@2.1.1: {}
diff --git a/src/layouts/MarkdownPost.astro b/src/layouts/MarkdownPost.astro
index 581a364..c211a25 100644
--- a/src/layouts/MarkdownPost.astro
+++ b/src/layouts/MarkdownPost.astro
@@ -76,7 +76,9 @@ const dateFormatted = formatDate(pubDate)
-
- 作者: {frontmatter.author} 发表日期:{dateFormatted} + 作者: + { + typeof frontmatter.author === "object" + ? {frontmatter.author.name} + : frontmatter.author + } + ,发表日期:{dateFormatted}