0.1.43 โ€ข Published 1 year ago

table-notion v0.1.43

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

A Vue 3 renderer for Notion pages (ported from vue-notion). Special thanks to Jannik Siebert & all the vue-notion contributors that made the vue-notion possible!

Use Notion as CMS for your blog, documentation or personal site. Also check out react-notion (developed by Splitbee ๐Ÿ โ€“ a fast, reliable, free, and modern analytics for any team)

This package doesn't handle the communication with the API (I planned to add this!). Check out notion-api-worker from Splitbee for an easy solution.

Created by Zernonia

Features

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

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

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

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

Install

Vue 3

npm install vue3-notion
# yarn add vue3-notion

Nuxt3 Module

Install as a dev-dependency and add "vue3-notion/nuxt" to the buildModules array in nuxt.config.js.

npm install vue3-notion --save-dev
// nuxt.config.ts
import { defineNuxtConfig } from "nuxt3"

export default defineNuxtConfig({
  //...
  modules: [
    ["vue3-notion/nuxt", { css: true }], // css is not imported by default. Set `true` to import css
  ],
})

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.

Basic Example for Vue 3

This example is a part of demo/ and is hosted at vue3-notion.vercel.app.

<script setup lang="ts">
import { NotionRenderer, getPageBlocks, useGetPageBlocks } from "vue3-notion"
import { ref, onMounted } from "vue"

const data = ref()

onMounted(async () => {
  data.value = await getPageBlocks("4b2dc28a5df74034a943f8c8e639066a")
})

// ---- or using Composables ----

const { data } = useGetPageBlocks("4b2dc28a5df74034a943f8c8e639066a")
</script>

<template>
  <NotionRenderer v-if="data" :blockMap="data" fullPage />
</template>

<style>
@import "vue3-notion/dist/style.css"; /* optional Notion-like styles */
@import "prismjs/themes/prism.css";
@import "katex/dist/katex.min.css";
</style>

Basic Example for Nuxt3

This example is a part of demo/ and is hosted at vue3-notion.vercel.app.

<script setup lang="ts">
const { $notion } = useNuxtApp()
const { data } = await useAsyncData("notion", () => $notion.getPageBlocks("2e22de6b770e4166be301490f6ffd420"))
</script>

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

Supported Blocks

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

Block TypeSupportedNotes
Textโœ… Yes
Headingโœ… Yes
Imageโœ… Yes
Image Captionโœ… Yes
Bulleted Listโœ… Yes
Numbered Listโœ… Yes
Quoteโœ… Yes
Calloutโœ… Yes
Columnโœ… Yes
iframeโœ… Yes
Videoโœ… YesOnly embedded videos
Dividerโœ… Yes
Linkโœ… Yes
Codeโœ… Yes
Web Bookmarkโœ… Yes
Toggle Listโœ… Yes
Page Linksโœ… Yes
Coverโœ… YesEnable with fullPage
Equationsโœ… Yes
Checkboxโœ… Yes
Simple Tablesโœ… Yes
Table Of Contentsโœ… Yes
Databasesโ˜‘๏ธ working on it

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

๐ŸŒŽ Local Development

Prerequisites

Yarn

  • npm install --global yarn

Development

  1. Clone the repo
    git clone https://github.com/zernonia/vue3-notion.git
  2. Install NPM packages
    yarn
  3. Run Development instance
    yarn dev

Credits

License โš–๏ธ

MIT ยฉ zernonia