Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions dev/serve.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import Vue from 'vue';
import Dev from './serve.vue';
import Vue from "vue";
import Dev from "./serve.vue";

import VueKatex from "vue-katex";

Vue.config.productionTip = false;

Vue.use(VueKatex);

new Vue({
render: (h) => h(Dev),
}).$mount('#app');
}).$mount("#app");
2 changes: 2 additions & 0 deletions dev/serve.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { NotionRenderer, getPageBlocks } from "@/entry";

import "prismjs";
import "prismjs/themes/prism.css";
import "katex/dist/katex.min.css";

export default {
name: "ServeDev",
Expand All @@ -20,6 +21,7 @@ export default {
},
async created() {
// react-notion tester: 2e22de6b770e4166be301490f6ffd420
// equation tester: 2a1d5226d68246deba627012081693f9
this.blockMap = await getPageBlocks("2e22de6b770e4166be301490f6ffd420");
},
};
Expand Down
22 changes: 22 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

Expand Down Expand Up @@ -110,6 +111,27 @@ import "prismjs/themes/prism.css";
> ⚠️ To keep file size down, Prism.js only includes `markup`, `css`, `clike`, and `javascript` languages per default.
> To add supported languages import the language component from Prism.js – e.g. `import 'prismjs/components/prism-rust'` for `rust`.

## Equations

The following steps are required to display equations via katex

- Install `vue-katex` to your project – `npm install vue-katex`
- Import the katex css in your project

```js
import "katex/dist/katex.min.css";
```

- Install the Vue plugin globally

```js
import Vue from "vue";
import VueKatex from "vue-katex";
Vue.use(VueKatex);
```

> For usage with Nuxt, look at the `/example` (`plugins` in `nuxt.config.js`, `plugins/vue-katex.js`)

## Notion API

The official Notion API is currently in [private beta](https://www.notion.so/api-beta).
Expand Down
3 changes: 3 additions & 0 deletions example/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ export default {

// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: ["vue-notion/nuxt"],

// Plugins (e.g. vue-katex for equations)
plugins: ["~/plugins/vue-katex.js"],
};
5 changes: 5 additions & 0 deletions example/plugins/vue-katex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Vue from "vue";
import VueKatex from "vue-katex";
import "katex/dist/katex.min.css";

Vue.use(VueKatex);
77 changes: 76 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
},
"peerDependencies": {
"prismjs": "^1.22.0",
"vue": "^2.6.14"
"vue": "^2.6.14",
"vue-katex": "^0.5.0"
},
"engines": {
"node": ">=10"
Expand Down
9 changes: 7 additions & 2 deletions src/blocks/decorator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
class="notion-link"
target="_blank"
:href="decoratorValue"
>{{ pageLinkTitle }}</a
>
>{{ pageLinkTitle }}
</a>
<span v-else-if="decorators.length === 0">{{ text }}</span>
<span v-else-if="decoratorKey === 'h'" :class="'notion-' + decoratorValue"
><NotionDecorator :content="nextContent" v-bind="pass" />
Expand All @@ -30,6 +30,11 @@
>
<NotionDecorator :content="nextContent" v-bind="pass" />
</a>
<component
v-else-if="decoratorKey === 'e'"
:is="'katex-element'"
:expression="decoratorValue"
/>
<NotionDecorator v-else :content="nextContent" v-bind="pass" />
</template>

Expand Down