A PHP/Laravel package to fetch Notion Pages and convert it to HTML!

Overview

Generate HTML from Notion Page

This package converts all the blocks in a Notion page into HTML using Notion's API. For more details on Notion API, please refer this page: https://developers.notion.com/

Currently, the Notion API returns the content in a form of JSON. You can see example for JSON format here: https://codebeautify.org/jsonviewer/y222f395f for this page: https://tested-wheel-e55.notion.site/Example-Page-6927be844d994e51bdda5f0c903f6788

Our renderer converts the JSON and converts it into HTML (converting to Markdown is work in progress), which you can use to render in your web application.


Installation

You can install the package via composer:

composer require rehan/laravel-notion-renderer

Usage

$pageHTML = (new NotionRenderer('yourPageId'))->html();

That's it 🎉

Your Notion Page is now converted to HTML and can use displayed in your web application.

Recommendation: We suggest to use https://tailwindcss.com/docs/typography-plugin to style the HTML (or you may use your own CSS for the styling).

Note: The NotionRenderer class extensively uses Notion's Block API (https://developers.notion.com/reference/get-block-children) to get the content of the Notion Page. Also, your API key must be present at .env file, check the config file of the package for more details.


Supported Block List:

Only the below blocks are currently Supported, but more blocks are coming soon.

  • Paragraph
  • Heading One
  • Heading Two
  • Heading Three
  • Quote
  • Numbered List
  • Bulleted List
  • Image
  • Table

Full list of blocks can be found here: https://developers.notion.com/reference/block

Note: Other blocks are under development


Service Classes (Optional to Use)

The package contains the following service classes:

NotionBlocks

Usage

$notionPageAsBlocks = (new NotionBlocks())->fetch('yourPageId')

NotionDatabase

Usage

$notionDatabase = (new NotionDatabase())->fetch('yourDatabaseId')

NotionPage

Usage

$notionPage = (new NotionDatabase())->fetch('yourPageId')

Note

For this to work, you need to create Integration and share the page with the Integration. For more details on obtaining and creating Integrations, please refer this page: https://www.notion.so/my-integrations

Credits

License

The MIT License (MIT). Please see License File for more information.

You might also like...
In order to use the Korean Language on your Magento 2 store, it is time to start with Magento 2 Korean Language Pack in the set of informative documentations by Mageplaza. Magento 2 Korean Language Package is published by Magento 2 Translation Project at Crowdin, so all phrases will be replaced by the Korean language according to the contribution to that project. Please following up the guides in this post to convert the language with ease! A Magento 2 module that allows admins to duplicate CMS blocks and pages from their respective grids and en masse.
A Magento 2 module that allows admins to duplicate CMS blocks and pages from their respective grids and en masse.

element119 | CMS Duplicator 📝 Features ✔️ Allows merchants to duplicate CMS blocks and pages from the Action column in the admin grid ✔️ Allows merch

Simple PHP Pages - A simple puristic PHP Website Boilerplate
Simple PHP Pages - A simple puristic PHP Website Boilerplate

Simple PHP Pages - A simple puristic PHP Website Boilerplate 🚀 Hey! This project provides simple and basic concepts for PHP pages. It includes ideas

This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.

Kirby 3 Many To Many Field This plugin allows you to create many-to-many relationships between pages in Kirby.

Allow SVG images to be used in Magento CMS blocks and pages via the TinyMCE Wysiwyg Editor.
Allow SVG images to be used in Magento CMS blocks and pages via the TinyMCE Wysiwyg Editor.

Hyvä Themes - SVG support for the Magento CMS Wysiwyg Editor Allow SVG images to be used in CMS blocks and pages via the TinyMCE Wysiwyg Editor. hyva-

Sync Wordpress Pages and Posts (even custom post types + fields) from static Markdown + YAML files

Sync Markdown Files to WordPress Posts and Pages Static site generators let you use a revision-controlled tree of markdown files to make a site, but d

A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.
A FREE Wordpress Plugin to compress and convert images using cwebp, jpegoptim and optipng.

Squidge Is FREE WordpPress Plugin built for developers in mind compressing and convert images using jpegoptim, optipng, cwebp, and libavif. It's extre

PHP class for convert KA letters to LAT and back

Kautilities PHP class for convert KA letters to LAT and back Installation Install this package through Composer. Edit your project's composer.json fil

Extracts information about web pages, like youtube videos, twitter statuses or blog articles.
Extracts information about web pages, like youtube videos, twitter statuses or blog articles.

Essence is a simple PHP library to extract media information from websites, like youtube videos, twitter statuses or blog articles. If you were alread

Comments
  • Implement Divider Block

    Implement Divider Block

    Introduction

    To see this Laravel Package in action, visit: Evaluate Blogs, the whole blogging system lives in Notion and renders in the web page using this package and styled using TailwindCSS Typography

    Requirements

    To implement Notion's Divider block, more info here: https://developers.notion.com/reference/block#divider-blocks

    Tasks

    • [x] Request to be assigned to the task
    • [x] Get assigned to the task
    • [x] Implement Callout Block
    • [x] Test thoroughly
    • [x] Add Screenshots/Video Recordings as POW

    Notes

    Just use the same Block Skeleton used for other blocks if you are unable to grasp the current code base. Also, if you have any ideas to improve the Block's Skelton, feel free!

    Happy Coding

    hacktoberfest 
    opened by zusamarehan 1
  • Add Callout block

    Add Callout block

    As per issue #2 Implement Callout Block, implemented Callout block rendering. It supports most of the features of callout blocks including rendering emojis, images as icons, background colors, font colors.

    Proof

    • Notion:

    image

    • Rendered Output:

    image

    opened by Bhuvi100 1
  • Implement Code Block

    Implement Code Block

    Introduction

    To see this Laravel Package in action, visit: Evaluate Blogs, the whole blogging system lives in Notion and renders in the web page using this package and styled using TailwindCSS Typography

    Requirements

    To implement Notion's Code block, more info here: https://developers.notion.com/reference/block#code-blocks

    Tasks

    • [ ] Request to be assigned to the task
    • [ ] Get assigned to the task
    • [ ] Implement Callout Block
    • [ ] Test thoroughly
    • [ ] Add Screenshots/Video Recordings as POW

    Notes

    Just use the same Block Skeleton used for other blocks if you are unable to grasp the current code base. Also, if you have any ideas to improve the Block's Skelton, feel free!

    Happy Coding

    hacktoberfest 
    opened by zusamarehan 0
  • Implement Callout Block

    Implement Callout Block

    Introduction

    To see this Laravel Package in action, visit: Evaluate Blogs, the whole blogging system lives in Notion and renders in the web page using this package and styled using TailwindCSS Typography

    Requirements

    To implement Notion's Callout block, more info here: https://developers.notion.com/reference/block#callout-blocks.

    Tasks

    • [ ] Request to be assigned to the task
    • [ ] Get assigned to the task
    • [ ] Implement Callout Block
    • [ ] Test thoroughly
    • [ ] Add Screenshots/Video Recordings as POW

    Notes

    Just use the same Block Skeleton used for other blocks if you are unable to grasp the current code base. Also, if you have any ideas to improve the Block's Skelton, feel free!

    Happy Coding

    hacktoberfest 
    opened by zusamarehan 0
Releases(1.2.0)
Owner
Usama Rehan
Full Stack Web Developer
Usama Rehan
N2Web turns your Notion HTML export into a fully functional static website

Notion2Web N2Web turns your Notion HTML export into a fully functional static website. What is Notion? Notion is an online tool. But I can't tell you

Lars Lehmann 15 Nov 23, 2022
A Magento 2 module that allows for creating discrete PDP (Product Detail Pages) page layouts for customers landing on the site from a PPC (Pay Per Click) link/ad by allowing routing to the same pages using a `/ppc/` prefix in the URL path.

A Magento 2 module that allows for creating discrete PDP (Product Detail Pages) page layouts for customers landing on the site from a PPC (Pay Per Click) link/ad by allowing routing to the same pages using a `/ppc/` prefix in the URL path.

null 16 Nov 11, 2022
A PHP component to convert HTML into a plain text format

html2text html2text is a very simple script that uses DOM methods to convert HTML into a format similar to what would be rendered by a browser - perfe

Jevon Wright 423 Dec 29, 2022
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

Matias Navarro Carter 105 Jan 4, 2023
a Telegram bot to fetch download link from pan.baidu.com

baiduwp-bot a Telegram bot to fetch download link from pan.baidu.com What it can do Get a file download link from share link. 从分享链接获取下载地址 How to use G

Yuan_Tuo 23 Dec 3, 2022
This package provides a wrapper for Google Lighthouse to audit the quality of web pages with Laravel.

laravel-google-lighthouse This package is based on octoper/lighthouse-php. This package provides a wrapper for Google Lighthouse to audit the quality

Logiek 5 Jun 1, 2022
Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format

Number to Bangla Number, Word or Month Name in Laravel | Get Wordpress Plugin Laravel package to convert English numbers to Bangla number or Bangla te

Md. Rakibul Islam 50 Dec 26, 2022
html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users

html-sanitizer html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing yo

Titouan Galopin 381 Dec 12, 2022
A package to render form fields in WordPress settings pages.

WP Settings Page Fields A package to render form fields in WordPress settings pages. You might need a settings page with a form and its fields and you

Roel Magdaleno 5 Jul 22, 2022
Sanitize untrustworthy HTML user input (Symfony integration for https://github.com/tgalopin/html-sanitizer)

html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing you to store it and display it safely. It has sensible defaults to provide a great developer experience while still being entierely configurable.

Titouan Galopin 86 Oct 5, 2022