Skip to content

Commit

Permalink
添加功能:
Browse files Browse the repository at this point in the history
- 支持 emoji 表情
- 支持 KaTeX 数学公式
  • Loading branch information
zouzonghao committed Jan 10, 2025
1 parent ff1aa4d commit b25a739
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 6 deletions.
19 changes: 15 additions & 4 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import { siteConfig } from "./src/site.config";
import vercel from "@astrojs/vercel";

// Remark plugins
import remarkDirective from "remark-directive";/* Handle ::: directives as nodes */
import { remarkAdmonitions } from "./src/plugins/remark-admonitions";/* Add admonitions */
import remarkDirective from "remark-directive"; // Handle ::: directives as nodes
import { remarkAdmonitions } from "./src/plugins/remark-admonitions"; // Add admonitions
import { remarkReadingTime } from "./src/plugins/remark-reading-time";
import remarkMath from "remark-math"; // Add LaTeX support
import remarkGemoji from "remark-gemoji"; // Add emoji support

// Rehype plugins
import rehypeExternalLinks from "rehype-external-links";
import rehypeUnwrapImages from "rehype-unwrap-images";
import rehypeKatex from "rehype-katex"; // Render LaTeX with KaTeX


import decapCmsOauth from "astro-decap-cms-oauth";

Expand Down Expand Up @@ -84,8 +88,15 @@ export default defineConfig({
},
],
rehypeUnwrapImages,
rehypeKatex, // 添加 KaTeX 用于 LaTeX 渲染
],
remarkPlugins: [
remarkReadingTime,
remarkDirective,
remarkAdmonitions,
remarkMath, // 添加 LaTeX 功能
remarkGemoji, // 添加 emoji 功能
],
remarkPlugins: [remarkReadingTime, remarkDirective, remarkAdmonitions],
remarkRehype: {
footnoteLabelProperties: {
className: [""],
Expand All @@ -96,7 +107,7 @@ export default defineConfig({
// https://docs.astro.build/en/guides/prefetch/
prefetch: {
defaultStrategy: 'viewport',
prefetchAll: true
prefetchAll: true,
},
// ! 改为你的网站地址,不然社交图片无法加载
site: "https://demo.343700.xyz/",
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
"satori-html": "^0.3.2",
"sharp": "^0.33.5",
"unified": "^11.0.5",
"unist-util-visit": "^5.0.0"
"unist-util-visit": "^5.0.0",
"rehype-katex": "^7.0.1",
"remark-gemoji": "^8.0.0",
"remark-math": "^6.0.0"
},
"devDependencies": {
"@astrojs/check": "^0.9.4",
Expand Down
114 changes: 114 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/layouts/Base.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ const {
<html class="scroll-smooth" lang={siteConfig.lang}>
<head>
<BaseHead articleDate={articleDate} description={description} ogImage={ogImage} title={title} />
</head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
/></head
>
<!-- 修改 max-w-6xl 最大宽度-->
<body
class="mx-auto flex min-h-screen max-w-4xl flex-col bg-bgColor px-4 pt-16 font-mono text-sm font-normal text-textColor antialiased sm:px-8"
Expand Down

0 comments on commit b25a739

Please sign in to comment.