All Projects → n6g7 → notion-cms

n6g7 / notion-cms

Licence: other
Notion as a headless CMS

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to notion-cms

Notion Clone
Stars: ✭ 2,048 (+2594.74%)
Mutual labels:  notion
Notion-GCal-Sync
A Python script to automate the syncing of tasks between Google Calendar and the all-in-one productivity workspace, Notion. It utilizes API and is customizable for your own needs. Free to use.
Stars: ✭ 120 (+57.89%)
Mutual labels:  notion
notion-heroku
Heroku hosted application that performs Notion actions (i.e., new task, new note) based on voice requests via IFTTT Webhooks and Google Assistant.
Stars: ✭ 41 (-46.05%)
Mutual labels:  notion
Notion Enhancer
an enhancer/customiser for the all-in-one productivity workspace notion.so (app)
Stars: ✭ 3,114 (+3997.37%)
Mutual labels:  notion
Notion-Boost-browser-extension
Chrome & Firefox extension for Notion to add 20+ features like sticky outline, small text & full width by default, hide comments & help button, bolder text etc. Download here: https://gourav.io/notion-boost
Stars: ✭ 367 (+382.89%)
Mutual labels:  notion
notionblog
My personal blog developed with notion.so api.
Stars: ✭ 78 (+2.63%)
Mutual labels:  notion
notion-linux
Native Notion packages for Linux
Stars: ✭ 887 (+1067.11%)
Mutual labels:  notion
typora notion-theme
My customisations for Typora to look a little more like Notion.so
Stars: ✭ 32 (-57.89%)
Mutual labels:  notion
tweaks
a collection of user-submitted css/js tweaks for notion
Stars: ✭ 85 (+11.84%)
Mutual labels:  notion
notion-scholar
Reference management solution using Python and Notion.
Stars: ✭ 77 (+1.32%)
Mutual labels:  notion
Notion Blog
A Next.js site using new SSG support with a Notion backed blog
Stars: ✭ 2,339 (+2977.63%)
Mutual labels:  notion
cm-page-builder
Page builder package like notion
Stars: ✭ 29 (-61.84%)
Mutual labels:  notion
tickety-tick
A browser extension that helps you name branches and write better commit messages
Stars: ✭ 55 (-27.63%)
Mutual labels:  notion
React Notion
A fast React renderer for Notion pages
Stars: ✭ 2,105 (+2669.74%)
Mutual labels:  notion
cards
Turn your Notion database into a deck of cards
Stars: ✭ 37 (-51.32%)
Mutual labels:  notion
Lotion
Unofficial Notion.so app for Linux
Stars: ✭ 1,735 (+2182.89%)
Mutual labels:  notion
notion-sites
发掘Notion好站
Stars: ✭ 519 (+582.89%)
Mutual labels:  notion
nast
A block-based intermediate representation for document-like content.
Stars: ✭ 35 (-53.95%)
Mutual labels:  notion
notion widgets
A set of HTML widgets that could be embedded into Notion.so https://www.notion.so/ pages. For more see https://blog.shorouk.dev/notion-widgets-gallery/
Stars: ✭ 270 (+255.26%)
Mutual labels:  notion
notion-cli-list-manager
A simple command-line tool for managing Notion databases.
Stars: ✭ 76 (+0%)
Mutual labels:  notion

notion-cms

Use notion.so as a headless CMS.

Installation

Choose one:

  • yarn add @notion-cms/client @notion-cms/react
  • npm install @notion-cms/client @notion-cms/react

Usage

Setting up a Notion integration

As of v0.1.0 notion-cms uses the official Notion API which enables us to cleanly read data from Notion, manage access permissions, etc. To use the Notion API we need to create a Notion integration:

  • Go to https://www.notion.so/my-integrations and create an integration for your project.
  • If you're using Notion as a CMS typically read access will be enough (no need for insert or update capabilities). Adapt to your own needs.
  • Copy the integration token.
  • Share any page you need access to with the newly created integration.

Setting up a collection

The easiest way to setup your CMS data on Notion is to use collections (aka "databases"): A collection on Notion.so

Use properties of any type to represent your data.

Loading data

  • The first thing you need to load your collection data is to instanciate a Notion client using the integration token from above:

    import Notion from "@notion-cms/client";
    export const notion = new Notion({ auth: process.env.NOTION_API_KEY });
  • Then we will setup a Typescript interface to match our collection property:

    import Notion, {
      DatabaseProps,
      ParsedPage,
      ParsedPageWithBlocks,
    } from "@notion-cms/client";
    
    export type Duration =
      | "Short (0-15 min)"
      | "Medium (15-30 min)"
      | "Long (30+ min)";
    export type HealthLevel = "Indulging" | "Comforting" | "Energising";
    interface RecipeProps extends DatabaseProps {
      Name: string;
      "Health score": HealthLevel;
      "Preparation time (min)": Duration;
      "Cooking time (min)": Duration;
      Serves: number;
    }
    export interface Recipe extends ParsedPage<RecipeProps> {}
    export interface RecipeWithBlocks extends ParsedPageWithBlocks<RecipeProps> {}

    The ParsedPage generic interface wraps the collection properties (aka props, which extend DatabaseProps) as well as meta data (page cover and icon). The ParsedPageWithBlocks interface also contains page blocks.

  • Then we're going to extract the UUID of the collection we wish to load. One way to find this UUID is to run the following script in the browser console:

    document
      .querySelectorAll(
        ".notion-collection_view-block > div > .notion-collection_view-block"
      )
      .forEach((collection) =>
        console.log(
          collection.querySelector("[spellcheck]").textContent,
          ":",
          collection.attributes["data-block-id"].nodeValue
        )
      );

    This will print the UUIDs of all the collections in the current page.

  • Finally we can call the notion.loadDatabase method to load entries in a database (without blocks):

    const recipesCollectionId = "bc0e5612-c5a1-4e3d-9d63-13bac995e5a2";
    
    const getRecipes = (): Promise<Recipe[]> =>
      notion.loadDatabase(recipesCollectionId, {});

    Or the notion.loadPage method to load a single page (with blocks):

    const getRecipe = (recipeId: string): Promise<RecipeWithBlocks> =>
      notion.loadPage(recipeId);

Rendering blocks

Once a Notion page has been loaded it can be easily rendered with @notion-cms/react:

import { Blocks } from "@notion-cms/react";

const PageComponent = ({ page }) => (
  <div>
    <Blocks blocks={page.blocks} />
  </div>
);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].