Skip to content

Commit 4a09e3c

Browse files
author
William Kim
committed
inline-equation added
1 parent b8e0773 commit 4a09e3c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

dev/serve.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export default {
2020
},
2121
async created() {
2222
// react-notion tester: 2e22de6b770e4166be301490f6ffd420
23-
this.blockMap = await getPageBlocks("2e22de6b770e4166be301490f6ffd420");
23+
// Equation terser: add9966dd1ae4d839ccec39150f90c5d
24+
this.blockMap = await getPageBlocks("add9966dd1ae4d839ccec39150f90c5d");
2425
},
2526
};
2627
</script>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"dependencies": {
3030
"cross-fetch": "^3.0.6",
3131
"defu": "^5.0.0",
32+
"katex": "^0.13.16",
3233
"vue-fragment": "^1.5.1",
3334
"vue-prism-component": "^1.2.0"
3435
},

src/blocks/decorator.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
class="notion-link"
55
target="_blank"
66
:href="decoratorValue"
7-
>{{ pageLinkTitle }}</a
8-
>
7+
>{{ pageLinkTitle }}
8+
</a>
99
<span v-else-if="decorators.length === 0">{{ text }}</span>
1010
<span v-else-if="decoratorKey === 'h'" :class="'notion-' + decoratorValue"
1111
><NotionDecorator :content="nextContent" v-bind="pass" />
@@ -30,11 +30,17 @@
3030
>
3131
<NotionDecorator :content="nextContent" v-bind="pass" />
3232
</a>
33+
<span
34+
v-else-if="decoratorKey === 'e'"
35+
v-html="inlineEquation"
36+
/>
3337
<NotionDecorator v-else :content="nextContent" v-bind="pass" />
3438
</template>
3539

3640
<script>
3741
import Blockable, { blockProps } from "@/lib/blockable";
42+
import katex from 'katex';
43+
import 'katex/dist/katex.css';
3844
3945
export default {
4046
extends: Blockable,
@@ -66,6 +72,11 @@ export default {
6672
isPageLink() {
6773
return this.text === "";
6874
},
75+
inlineEquation() {
76+
return katex.renderToString(this.decoratorValue, {
77+
throwOnError: false,
78+
});
79+
},
6980
pageLinkTitle() {
7081
return (
7182
this.blockMap?.[this.decoratorValue]?.value?.properties
@@ -74,4 +85,4 @@ export default {
7485
},
7586
},
7687
};
77-
</script>
88+
</script>

0 commit comments

Comments
 (0)