Notion Blog React Documentation
What is this
Notion Blog React is a Blog powered by Notion, built with React, Next.JS, tailwindcss, TypeScript, Notion-Api-Worker and more.
TL;DR
- Fork the Notion Blog React (opens in a new tab) from GitHub.
- Change setting in
config/site.config.js
(opens in a new tab) file. - Import to Vercel by clicking this quick link (opens in a new tab).
- Add two environment variables
NOTION_API
andNOTION_TABLE_SLUG
to Vercel configuration. - Deploy it.
You can now visit the link generated by Vercel.
Complete Deployment Guide
If you are interested in this project, you can have a try it by using the doing the following things.
To do the following, you need to have GitHub account ready.
Fork this project
Visiting Notion Blog React (opens in a new tab) on GitHub, and click the fork
on the top right.
Change the site configuration
Enter config/site.config.js
(opens in a new tab), change the configuration.
See details about the each variable
module.exports = {
global: {
author: {
name: 'Harry Yep', // The Blog author
github: 'https://github.com/okisdev/Notion-Blog-React', // The Blog author GitHub
email: '[email protected]', // The Blog author email
privacy_policy: 'https://www.harrly.com/privacy-policy', // The Blog Privacy Policy
},
site: {
name: 'Notion Blog React Example', // The Blog title
description: 'Blog built with Notion, React, Next.js, tailwindcss, TypeScript, Notion-Api-Worker and more.', // The Blog description
url: 'https://nbr.okis.dev/', // The blog URL
banner_img: `https://cdn.harrly.com/project/GitHub/Notion-Blog-React/img/Notion-Blog-React.Banner.png`, // The Blog Open Graph image
language: [
// The supported language of the Blog (Not recommand to change, only support **简体中文** and **British England** so far)
{
name: 'British English', // The language name (Default is **British English**)
code: 'en-GB', // The language code, this is related the URL you visited. For example, `blog.example.com/zh-CN` stand for **简体中文** of the blog.
},
{
name: 'Simplified Chinese',
code: 'zh-CN',
},
],
},
content: {
header: {
description: `...`, // The description of the Blog, which will be shown on the header of the page. JSX supported.
image_url: 'https://cdn.harrly.com/global/assets/icon/android-chrome-192x192.png', // The header image
},
license: {
name: 'CC BY-NC-SA 4.0', // The License Name
url: 'https://creativecommons.org/licenses/by-nc-sa/4.0/', // The License agreement URL
},
},
analytics: {
google: '', // The Google Analytics UA Code
splitbee: 'O1KKIQNSGP18', // The Splitbee Analytics Code
},
},
};
Notion API Preparation
This will be one of the Environment Variable of your site, called NOTION_API
.
Please do not add http://
or https://
before NOTION_API
.
You can use notion-api.splitbee.io
if you don't want to make your own one.
Alternatively, see here (opens in a new tab) for how to deploy a notion-api by yourself.
Create the Database in Notion
This will be one of the Environment Variable of your site, called NOTION_TABLE_SLUG
.
You should create a notion table with below properties. (You can duplicate a template from here (opens in a new tab).)
See details about the each property
title: Title
tag: Multi-select
published: Checkbox
date: Date
slug: Text
author: Person
description: Text
Please don't leave blank in any property box, excepted checkbox and description.
An error will happen if you do so.
Deploy on Serverless platform
We have now finished the large part of configuration, it is time to deploy it.
You can choose to deploy it on any serverless which support Next.JS framework, we recommend Vercel (opens in a new tab), you can use Netlify (opens in a new tab), etc.
Please don't use Cloudflare Pages (opens in a new tab), they only support Next.JS Static Deploy at the moment.
-
To deploy it on Vercel, visit Vercel and click the New Project button.
-
Import your forked repository.
This is how configuration looks like.
It is important to add the
Environment Variables
, else, the deployment will fail. -
After all setup, click Deploy.
-
You can visit your website via Vercel auto-generated URL (If you deploy with Vercel, it should ending with
vercel.app
).
Deploy it locally
We have now finished the large part of configuration, it is time to deploy it.
You can download your whole project by clicking the Download ZIP on your GitHub, or you can clone it if you prefer to do so.
After that, please do the following things:
-
Open your project in an IDE, such as VSCode, or terminal, such as iterm2.
-
Create a
.env.local
in the root path of the project. -
Copy and paste from
.env.example
to.env.local
. -
Fill in the environment variables in
.env.local
.It is important to add the
Environment Variables
, else, the deployment will fail. -
Run
yarn
in your project. -
Run
yarn build && yarn start
in your project. -
You can now able to visit your website via
http://localhost:3000
.