Skip to content

Commit 09d7aa7

Browse files
committed
enable TeX math rendering with KaTeX
1 parent e34c816 commit 09d7aa7

5 files changed

Lines changed: 150 additions & 2 deletions

File tree

astro.config.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { defineConfig } from 'astro/config';
22
import vue from '@astrojs/vue';
33
import sitemap from '@astrojs/sitemap';
4+
import remarkMath from 'remark-math';
5+
import rehypeKatex from 'rehype-katex';
46

57
export default defineConfig({
68
site: 'https://rushdb-lab.github.io',
9+
markdown: {
10+
remarkPlugins: [remarkMath],
11+
rehypePlugins: [rehypeKatex],
12+
},
713
integrations: [
814
vue(),
915
sitemap({

package-lock.json

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"@astrojs/sitemap": "^3.2.0",
1414
"@astrojs/vue": "^5.0.0",
1515
"astro": "^5.0.0",
16+
"katex": "^0.16.28",
17+
"rehype-katex": "^7.0.1",
18+
"remark-math": "^6.0.0",
1619
"vue": "^3.5.13"
1720
},
1821
"devDependencies": {

src/content/blog/zh/miniob-vector-database.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ private:
7373
7474
### 3.1 距离计算的数学原理
7575
76-
对于两个 `n` 维向量 `a``b`,欧几里得距离(L2)定义为:
76+
对于两个 \(n\) 维向量 \(\mathbf{a}\)\(\mathbf{b}\),欧几里得距离(L2)定义为:
7777
78-
<p><strong>d(a, b) = ||a - b||<sub>2</sub> = √(Σ<sub>i=1</sub><sup>n</sup> (a<sub>i</sub> - b<sub>i</sub>)<sup>2</sup>)</strong></p>
78+
$$ d(\mathbf{a}, \mathbf{b}) = \|\mathbf{a} - \mathbf{b}\|_2 = \sqrt{\sum_{i=1}^{n} (a_i - b_i)^2} $$
7979
8080
在比较大小时,我们通常省略开方运算以减少 CPU 开销。
8181

src/layouts/BaseLayout.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import '../styles/global.css';
3+
import 'katex/dist/katex.min.css';
34
import { getI18n, type Lang } from '../i18n';
45
import NavBar from '../components/vue/NavBar.vue';
56
import BackToTop from '../components/vue/BackToTop.vue';

0 commit comments

Comments
 (0)