Skip to content

Commit f365455

Browse files
committed
feat: enable katex by default & compile local
1 parent 6233998 commit f365455

File tree

16 files changed

+235
-65
lines changed

16 files changed

+235
-65
lines changed

.github/workflows/demo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121

2222
steps:
23-
- uses: actions/checkout@v2
23+
- uses: actions/checkout@v3
2424

2525
- name: Install pnpm
2626
uses: pnpm/action-setup@v2

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
release:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313
with:
1414
fetch-depth: 0
1515

@@ -20,7 +20,7 @@ jobs:
2020

2121
# after pnpm
2222
- name: Use Node.js 16
23-
uses: actions/setup-node@v2
23+
uses: actions/setup-node@v3
2424
with:
2525
node-version: 16
2626
registry-url: https://registry.npmjs.org/

demo/yun/pages/docs/guide/features.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,20 @@ npm run rss
123123
## i18n in One Page
124124

125125
More info see [i18n](/docs/guide/i18n).
126+
127+
## KaTeX
128+
129+
默认的 KaTeX 支持。
130+
131+
```ts
132+
// valaxy.config.ts
133+
import { defineConfig } from 'valaxy'
134+
export default defineConfig({
135+
features: {
136+
// disable katex
137+
katex: false
138+
}
139+
})
140+
```
141+
142+
- [KaTeX | 示例 - Example](/examples/katex)

demo/yun/pages/examples/custom-components.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
---
22
title: 使用自定义组件
3+
categories:
4+
- Docs
5+
- Example
36
---
47

58
Use Custom Components

demo/yun/pages/examples/katex.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
title: KaTeX
3+
date: 2020-03-23 02:02:15
4+
updated: 2020-03-23 02:02:15
5+
toc: true
6+
categories:
7+
- Docs
8+
- Example
9+
---
10+
11+
## [KaTeX](https://katex.org/)
12+
13+
- <https://katex.org/docs/autorender.html>
14+
15+
### 行内公式
16+
17+
$\{x | Ax = b\}$
18+
19+
```md
20+
$\{x | Ax = b\}$
21+
```
22+
23+
$\mathcal{X}_{c^*}<1, \mathcal{X}_{q^*}<1$
24+
25+
$E = mc^2$
26+
27+
$\frac{\partial}{\partial t}$
28+
29+
```latex
30+
$E = mc^2$
31+
$\frac{\partial}{\partial t}$
32+
```
33+
34+
### 行间公式
35+
36+
$$ E = mc^2 $$
37+
38+
```latex
39+
$$ E = mc^2 $$
40+
```
41+
42+
---
43+
44+
$$ \vec a=\frac{d\vec v}{dt}=\frac{d(\frac{dr}{dt}\vec e*{i}+r\frac{d\theta}{dt}\vec e*{j})}{dt}=\frac{d^2r}{dt^2}\vec e*{i}+\frac{dr}{dt}\frac{d\vec e*{i}}{dt}+\frac{dr}{dt}\frac{d\theta}{dt}\vec e*{j}+r\frac{d^2\theta}{dt^2}\vec e*{j}+r\frac{d\theta}{dt}\frac{d\vec e\_{j}}{dt} $$
45+
46+
```latex
47+
$$ \vec a=\frac{d\vec v}{dt}=\frac{d(\frac{dr}{dt}\vec e_{i}+r\frac{d\theta}{dt}\vec e_{j})}{dt}=\frac{d^2r}{dt^2}\vec e_{i}+\frac{dr}{dt}\frac{d\vec e_{i}}{dt}+\frac{dr}{dt}\frac{d\theta}{dt}\vec e_{j}+r\frac{d^2\theta}{dt^2}\vec e_{j}+r\frac{d\theta}{dt}\frac{d\vec e_{j}}{dt} $$
48+
```
49+
50+
$$ m_t=g_t $$
51+
52+
$$ V_t=1 $$
53+
54+
```latex
55+
$$ m_t=g_t $$
56+
$$ V_t=1 $$
57+
```
58+
59+
$$ \eta_t=lr*{\frac {m_t}{\sqrt V_t}}=lr*g_t $$
60+
61+
$$ w\_{t+1}=w_t-\eta_t=w_t-lr*{\frac {m_t}{\sqrt V_t}}=w_t-lr*g_t $$
62+
63+
<div text="red">
64+
65+
$$
66+
q''_s = -k \left.\frac{\partial }{\partial x} (T_1+T_2) \right|_{x=0} = \underbrace{-k \left.\frac{\partial T_1}{\partial x} \right|_{x=0}}_{q''_s} -k \left.\frac{\partial T_2}{\partial x} \right|_{x=0} \rightarrow \boxed{0 = -k \left.\frac{\partial T_2}{\partial x} \right|_{x=0}}
67+
$$
68+
69+
</div>
70+
71+
```latex
72+
$$ \eta_t=lr*{\frac {m_t}{\sqrt V_t}}=lr*g_t $$
73+
$$ w_{t+1}=w_t-\eta_t=w_t-lr*{\frac {m_t}{\sqrt V_t}}=w_t-lr*g_t $$
74+
75+
<div text="red">
76+
77+
$$
78+
q''_s = -k \left.\frac{\partial }{\partial x} (T_1+T_2) \right|_{x=0} = \underbrace{-k \left.\frac{\partial T_1}{\partial x} \right|_{x=0}}_{q''_s} -k \left.\frac{\partial T_2}{\partial x} \right|_{x=0} \rightarrow \boxed{0 = -k \left.\frac{\partial T_2}{\partial x} \right|_{x=0}}
79+
$$
80+
81+
</div>
82+
```
83+
84+
$$
85+
\begin{bmatrix}
86+
a & b \\
87+
c & d
88+
\end{bmatrix}
89+
$$
90+
91+
```latex
92+
$$
93+
\begin{bmatrix}
94+
a & b \\
95+
c & d
96+
\end{bmatrix}
97+
$$
98+
```
99+
100+
$$
101+
\begin{equation}
102+
\left\{
103+
\begin{aligned}
104+
x=a\cos\theta\\
105+
y=b\sin\theta\\
106+
\end{aligned}
107+
\right.
108+
\end{equation}
109+
$$
110+
111+
```latex
112+
$$
113+
\begin{equation}
114+
\left\{
115+
\begin{aligned}
116+
x=a\cos\theta\\
117+
y=b\sin\theta\\
118+
end{aligned}
119+
\right.
120+
\end{equation}
121+
$$
122+
```

demo/yun/vite.config.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
import { defineConfig } from 'vite'
2-
import { VitePWA } from 'vite-plugin-pwa'
3-
import valaxyConfig from './valaxy.config'
2+
// import { VitePWA } from 'vite-plugin-pwa'
3+
// import valaxyConfig from './valaxy.config'
44

55
export default defineConfig({
66
plugins: [
7-
VitePWA({
8-
registerType: 'autoUpdate',
9-
includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
10-
manifest: {
11-
name: valaxyConfig.title || 'Theme Yun',
12-
short_name: valaxyConfig.title || 'Yun',
13-
theme_color: '#ffffff',
14-
icons: [
15-
{
16-
src: '/pwa-192x192.png',
17-
sizes: '192x192',
18-
type: 'image/png',
19-
},
20-
{
21-
src: '/pwa-512x512.png',
22-
sizes: '512x512',
23-
type: 'image/png',
24-
},
25-
{
26-
src: '/pwa-512x512.png',
27-
sizes: '512x512',
28-
type: 'image/png',
29-
purpose: 'any maskable',
30-
},
31-
],
32-
},
33-
}),
7+
// VitePWA({
8+
// registerType: 'autoUpdate',
9+
// includeAssets: ['favicon.svg', 'safari-pinned-tab.svg'],
10+
// manifest: {
11+
// name: valaxyConfig.title || 'Theme Yun',
12+
// short_name: valaxyConfig.title || 'Yun',
13+
// theme_color: '#ffffff',
14+
// icons: [
15+
// {
16+
// src: '/pwa-192x192.png',
17+
// sizes: '192x192',
18+
// type: 'image/png',
19+
// },
20+
// {
21+
// src: '/pwa-512x512.png',
22+
// sizes: '512x512',
23+
// type: 'image/png',
24+
// },
25+
// {
26+
// src: '/pwa-512x512.png',
27+
// sizes: '512x512',
28+
// type: 'image/png',
29+
// purpose: 'any maskable',
30+
// },
31+
// ],
32+
// },
33+
// }),
3434
],
3535
})

packages/valaxy/src/client/components/ValaxyMd.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import type { Post } from 'valaxy'
33
import { onMounted, ref } from 'vue'
44
import { useI18n } from 'vue-i18n'
5-
import { useAplayer, useCodePen, useKatex } from '~/composables'
5+
import { useAplayer, useCodePen } from '~/composables'
66
import { wrapTable } from '~/utils'
77
88
const props = defineProps<{
@@ -21,10 +21,6 @@ onMounted(() => {
2121
updateDom()
2222
})
2323
24-
// features
25-
if (props.frontmatter.katex)
26-
useKatex()
27-
2824
// widgets
2925
if (props.frontmatter.aplayer)
3026
useAplayer()
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export * from './katex'

packages/valaxy/src/client/composables/features/katex.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/valaxy/src/client/composables/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export * from './tag'
55

66
// common
77
export * from './common'
8-
export * from './features'
8+
// export * from './features'
99
export * from './helper'
1010
export * from './dark'
1111
export * from './layout'

0 commit comments

Comments
 (0)