• Stars
    star
    883
  • Rank 51,702 (Top 2 %)
  • Language Vue
  • License
    Other
  • Created almost 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A fast Vue renderer for Notion pages
vue-notion

An unofficial Notion renderer

Features ยท Install ยท Docs ยท Examples ยท Credits

Package version Compressed size MIT license Follow on Twitter


Features

๐ŸŽฏ Accurate โ€“ Results are almost identical

๐ŸŽจ Custom Styles โ€“ Styles are easily adaptable. Optional styles included

๐Ÿ”ฎ Syntax-Highlighting โ€“ Beautiful themeable code highlighting using Prism.js

๐ŸŒŽ SSR / Static Generation Support โ€“ Functions to work with NuxtJS and other frameworks

Install

Warning
This is the documentation for the upcoming Vue 3 compatible release of vue-notion. For the Vue 2 version, check out the vue2 branch.

Vue

npm install [email protected]

NuxtJS Module

Check out the /example folder for a full working example using Nuxt 3.

Docs

Note
Potentially outdated -- 3.0.0 docs are a work-in-progress

  • NotionRenderer: docs/
  • Syntax-Highlighting in Code Blocks (with Prism.js): docs/
  • Notion API: docs/
  • Nuxt: docs/

Check out a full working demo at vue-notion.now.sh โœจ The code for the demo is in example/.

Examples

These examples use a simple wrapper around the notion-api-worker to access the Notion page data. It is also possible to store a page received from the Notion API in .json and use it without the async/await part.

Use the getPageBlocks and getPageTable methods with caution! They are based on the private Notion API. We can NOT guarantee that it will stay stable. The private API is warpped by notion-api-worker. If you use these methods a lot, please consider hosting you own instance, as described in docs#notion-api.

Basic Example for Vue

This example is a part of example/ and is hosted at vue-notion.now.sh/vue.

<template>
  <NotionRenderer :blockMap="blockMap" fullPage />
</template>

<script lang="ts">
import { NotionRenderer, getPageBlocks } from "vue-notion";

export default {
  components: { NotionRenderer },
  data: () => ({ blockMap: null }),
  async created() {
    // get Notion blocks from the API via a Notion pageId
    this.blockMap = await getPageBlocks("8c1ab01960b049f6a282dda64a94afc7");
  },
};
</script>

<style>
/* optional Notion-like styles */
@import "vue-notion/src/styles.css";
</style>

Basic Example for NuxtJS

This example is a part of example/ and is hosted at vue-notion.now.sh/nuxt. The page assumes a Nuxt plugin in ~/plugins/vue-notion.js that registers via the useNuxtApp hook.

<template>
  <NotionRenderer :blockMap="blockMap" fullPage />
</template>

<script lang="ts" setup>
const { $notion } = useNuxtApp();

// use Notion module to get Notion blocks from the API via a Notion pageId
const { data: blockMap } = useAsyncData("page_nuxt", () =>
  $notion.getPageBlocks("8c1ab01960b049f6a282dda64a94afc7")
);
</script>

<style>
@import "vue-notion/src/styles.css"; /* optional Notion-like styles */
</style>

Sites using vue-notion ๐ŸŒŽ

List of pages that are using this library.

Supported Blocks

Most common block types are supported. We happily accept pull requests to add support for the missing blocks.

Block Type Supported Notes
Text โœ… Yes
Heading โœ… Yes
Image โœ… Yes
Image Caption โœ… Yes
Bulleted List โœ… Yes
Numbered List โœ… Yes
Quote โœ… Yes
Callout โœ… Yes
Column โœ… Yes
iframe โœ… Yes
Video โœ… Yes Only embedded videos
Divider โœ… Yes
Link โœ… Yes
Code โœ… Yes
Web Bookmark โœ… Yes
Toggle List โœ… Yes
Page Links โœ… Yes
Cover โœ… Yes Enable with fullPage
Equations โœ… Yes
Checkbox โœ… Yes
Simple Tables โœ… Yes
Databases โŒ Not planned
Table Of Contents โŒ Not planned

Please, feel free to open an issue if you notice any important blocks missing or anything wrong with existing blocks.

Credits

License โš–๏ธ

MIT ยฉ Jannik Siebert