Skip to content

Commit 7c2955e

Browse files
committed
Update katex usage
1 parent 4a09e3c commit 7c2955e

File tree

7 files changed

+92
-15
lines changed

7 files changed

+92
-15
lines changed

dev/serve.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import Vue from 'vue';
2-
import Dev from './serve.vue';
1+
import Vue from "vue";
2+
import Dev from "./serve.vue";
3+
4+
import VueKatex from "vue-katex";
35

46
Vue.config.productionTip = false;
57

8+
Vue.use(VueKatex);
9+
610
new Vue({
711
render: (h) => h(Dev),
8-
}).$mount('#app');
12+
}).$mount("#app");

dev/serve.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { NotionRenderer, getPageBlocks } from "@/entry";
99
1010
import "prismjs";
1111
import "prismjs/themes/prism.css";
12+
import "katex/dist/katex.min.css";
1213
1314
export default {
1415
name: "ServeDev",
@@ -20,8 +21,8 @@ export default {
2021
},
2122
async created() {
2223
// react-notion tester: 2e22de6b770e4166be301490f6ffd420
23-
// Equation terser: add9966dd1ae4d839ccec39150f90c5d
24-
this.blockMap = await getPageBlocks("add9966dd1ae4d839ccec39150f90c5d");
24+
// equation tester: 2a1d5226d68246deba627012081693f9
25+
this.blockMap = await getPageBlocks("2e22de6b770e4166be301490f6ffd420");
2526
},
2627
};
2728
</script>

example/nuxt.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ export default {
2121

2222
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
2323
buildModules: ["vue-notion/nuxt"],
24+
25+
// Plugins (e.g. vue-katex for equations)
26+
plugins: ["~/plugins/vue-katex.js"],
2427
};

example/plugins/vue-katex.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Vue from "vue";
2+
import VueKatex from "vue-katex";
3+
4+
Vue.use(VueKatex);

package-lock.json

Lines changed: 71 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"dependencies": {
3030
"cross-fetch": "^3.0.6",
3131
"defu": "^5.0.0",
32-
"katex": "^0.13.16",
3332
"vue-fragment": "^1.5.1",
33+
"vue-katex": "^0.5.0",
3434
"vue-prism-component": "^1.2.0"
3535
},
3636
"devDependencies": {

src/blocks/decorator.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@
3030
>
3131
<NotionDecorator :content="nextContent" v-bind="pass" />
3232
</a>
33-
<span
33+
<component
3434
v-else-if="decoratorKey === 'e'"
35-
v-html="inlineEquation"
35+
:is="'katex-element'"
36+
:expression="decoratorValue"
3637
/>
3738
<NotionDecorator v-else :content="nextContent" v-bind="pass" />
3839
</template>
3940

4041
<script>
4142
import Blockable, { blockProps } from "@/lib/blockable";
42-
import katex from 'katex';
43-
import 'katex/dist/katex.css';
4443
4544
export default {
4645
extends: Blockable,
@@ -72,11 +71,6 @@ export default {
7271
isPageLink() {
7372
return this.text === "";
7473
},
75-
inlineEquation() {
76-
return katex.renderToString(this.decoratorValue, {
77-
throwOnError: false,
78-
});
79-
},
8074
pageLinkTitle() {
8175
return (
8276
this.blockMap?.[this.decoratorValue]?.value?.properties

0 commit comments

Comments
 (0)