Giter Club home page Giter Club logo

notion-markdown's Introduction

notion-markdown

Parse the Notion page as a Markdown

Installation

$ yarn add notion-markdown

Usage

import notion from 'notion-markdown';
import fetch from 'node-fetch';

fetch('https://www.notion.so/api/v3/loadPageChunk', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: `token_v2=<your cookie>`,
  },
  body: JSON.stringify({
    pageId: <your blog page id(if the id is 32 characters, it is still not normalized)>,
    limit: 50, // notion default setting,
    cursor: { stack: [] },
    chunkNumber: 0,
    verticalColumns: false,
  })
}).then(res => res.json()).then(res => {
  // Please put the contents of `res.recordMap.block` in the notion function.
  console.log(notion(Object.values(res.recordMap.block)));
});

API

notion

function notion(blocks: Block[]): string;

The Block has the following structure.

type Block = {
  role: string;
  value: {
    id: string;
    type: string;
    properties?: any;
  };
};

CHANGELOG

See CHANGELOG.md.

Contributing

welcoming your contribution ๐Ÿ‘

  1. Fork
  2. Create a feature branch
  3. Run test suite with the $ yarn test command and confirm that it passes
  4. Commit your changes
  5. Rebase your local changes against the master branch
  6. Create new Pull Request ๐ŸŽ‰

Bugs, feature requests and comments are more than welcome in the issues.

Development scripts

yarn test

Run Unit test with Jest.

$ yarn test

yarn lint

Run lint with ESLint.

$ yarn lint

yarn format

Run formatting with ESLint (--fix) and Prettier.

$ yarn format

License

MIT

notion-markdown's People

Contributors

dependabot[bot] avatar konojunya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.