Skip to content

Commit bd20544

Browse files
committed
Merge branch 'main' of github.com:janniks/vue-notion
2 parents 45bd240 + eaa77da commit bd20544

File tree

8 files changed

+124
-7
lines changed

8 files changed

+124
-7
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: 2 additions & 0 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,6 +21,7 @@ export default {
2021
},
2122
async created() {
2223
// react-notion tester: 2e22de6b770e4166be301490f6ffd420
24+
// equation tester: 2a1d5226d68246deba627012081693f9
2325
this.blockMap = await getPageBlocks("2e22de6b770e4166be301490f6ffd420");
2426
},
2527
};

docs/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- `NotionRenderer`: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs#notionrenderer)
44
- Syntax-Highlighting in Code Blocks (with Prism.js): [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs#syntax-highlighting)
5+
- Equations: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs#equations)
56
- Notion API: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs#notion-api)
67
- Nuxt: [`docs/`](https://github.com/janniks/vue-notion/tree/main/docs#nuxtjs--server-side-rendering--static-site-generation)
78

@@ -110,6 +111,27 @@ import "prismjs/themes/prism.css";
110111
> ⚠️ To keep file size down, Prism.js only includes `markup`, `css`, `clike`, and `javascript` languages per default.
111112
> To add supported languages import the language component from Prism.js – e.g. `import 'prismjs/components/prism-rust'` for `rust`.
112113
114+
## Equations
115+
116+
The following steps are required to display equations via katex
117+
118+
- Install `vue-katex` to your project – `npm install vue-katex`
119+
- Import the katex css in your project
120+
121+
```js
122+
import "katex/dist/katex.min.css";
123+
```
124+
125+
- Install the Vue plugin globally
126+
127+
```js
128+
import Vue from "vue";
129+
import VueKatex from "vue-katex";
130+
Vue.use(VueKatex);
131+
```
132+
133+
> For usage with Nuxt, look at the `/example` (`plugins` in `nuxt.config.js`, `plugins/vue-katex.js`)
134+
113135
## Notion API
114136

115137
The official Notion API is currently in [private beta](https://www.notion.so/api-beta).

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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Vue from "vue";
2+
import VueKatex from "vue-katex";
3+
import "katex/dist/katex.min.css";
4+
5+
Vue.use(VueKatex);

package-lock.json

Lines changed: 76 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
},
5757
"peerDependencies": {
5858
"prismjs": "^1.22.0",
59-
"vue": "^2.6.14"
59+
"vue": "^2.6.14",
60+
"vue-katex": "^0.5.0"
6061
},
6162
"engines": {
6263
"node": ">=10"

src/blocks/decorator.vue

Lines changed: 7 additions & 2 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,6 +30,11 @@
3030
>
3131
<NotionDecorator :content="nextContent" v-bind="pass" />
3232
</a>
33+
<component
34+
v-else-if="decoratorKey === 'e'"
35+
:is="'katex-element'"
36+
:expression="decoratorValue"
37+
/>
3338
<NotionDecorator v-else :content="nextContent" v-bind="pass" />
3439
</template>
3540

0 commit comments

Comments
 (0)