1.0.1 • Published 1 year ago

notion-private-page-to-html v1.0.1

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

Cover image

Private Notion Page To HTML

FORK FROM https://github.com/asnunes/notion-page-to-html

NodeJS tool to convert private notion pages to HTML.

Supported features

Most of the native Notion blocks are currently supported:

  • Headings
  • Text With Decorations
  • Quote
  • Image
  • YouTube Videos
  • Code
  • Math Equations
  • To-do
  • Checkbox
  • Bulleted Lists
  • Numbered Lists
  • Toggle Lists
  • Divider
  • Callout
  • Nested blocks

Embeds and tables are not supported yet.

Basic Usage

Install it in a NodeJS project using npm

npm install notion-private-page-to-html

Then, just import it and paste a private Notion page id

const NotionPageToHtml = require('notion-private-page-to-html');

// using async/await
async function getPage() {
  const { title, icon, cover, html } = await NotionPageToHtml.convert("page_Id", "notion_token");
  console.log(title, icon, cover, html);
}

getPage();

cover is a base64 string from original page cover image. icon can be an emoji or base64 image based on original page icon. html is a full html document by default. It has style, body, MathJax and PrismJS CDN scripts by default. You can pass some options to handle html content.

NotionPageToHtml.convert(
  pageId,
  notionToken
  options
);

options is an object with the following keys

KeyDefault valueIf true
excludeCSSfalsereturns html without style tag
excludeMetadatafalsereturns html without metatags
excludeScriptsfalsereturns html without script tags
excludeHeaderFromBodyfalsereturns html without title, cover and icon inside body
excludeTitleFromHeadfalsereturns html without title tag in head
bodyContentOnlyfalsereturns html body tag content only