Skip to content

Commit 99fc1e3

Browse files
committed
Rework README
1 parent 90ba245 commit 99fc1e3

File tree

1 file changed

+87
-27
lines changed

1 file changed

+87
-27
lines changed

README.md

Lines changed: 87 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
![react-notion](https://user-images.githubusercontent.com/1440854/79684011-6c948280-822e-11ea-9e23-1644903796fb.png)
22

3-
A renderer for Notion pages. It is written in TypeScript. Use Notion as CMS for your blog, documentation or personal site, while we wait for the official API.
3+
![npm version](https://badgen.net/npm/v/react-notion) ![npm version](https://badgen.net/david/dep/splitbee/react-notion) ![minzipped sized](https://badgen.net/bundlephobia/minzip/react-notion)
44

5-
This packages does not include an API wrapper. You can find some interesting projects here: [notionapi-agent](https://github.com/dragonman225/notionapi-agent)
5+
A React renderer for Notion pages.
6+
Use Notion as CMS for your blog, documentation or personal site.
7+
8+
_This packages doesn't handle the communication with the API._
9+
10+
## Features
11+
12+
⚡️ **Fast** – Up to 10x faster than Notion\*
13+
🎯 **Precise** – Results are _almost_ identical
14+
🔮 **Code Highlighting** – Automatic code highlighting with [prismjs](https://prismjs.com/)
15+
🎨 **Custom Styles** – Styles are easily adaptable. Optional styles included
16+
17+
_\* First Meaningful Paint compared to an example hosted on [ZEIT now](https://zeit.co/now)._
618

719
## Install
820

@@ -12,14 +24,17 @@ npm install react-notion
1224

1325
## How to use
1426

27+
#### Minimal Example
28+
29+
We can store the API response in a `.json` file and import it.
30+
1531
```js
16-
import { NotionRenderer } from "react-notion";
1732
import "react-notion/src/styles.css";
18-
1933
import "prismjs/themes/prism-tomorrow.css"; // only needed if you use Code Blocks
34+
import { NotionRenderer } from "react-notion";
35+
36+
import response from "./load-page-chunk-response.json"; // https://www.notion.so/api/v3/loadPageChunk
2037

21-
// Load Notion Data from JSON file. Can be replaced with API call.
22-
import response from "./load-page-chunk-response.json";
2338
const blockMap = response.recordMap.block;
2439

2540
export default () => (
@@ -29,37 +44,82 @@ export default () => (
2944
);
3045
```
3146

32-
A working example, built with Next.js, can be found inside the `example` directory.
47+
A working example can be found inside the `example` directory.
3348

34-
## Currently supported block types:
49+
#### Next.js Example
3550

36-
- [x] Text
37-
- [x] Headings
38-
- [x] Images
39-
- [x] Quotes
40-
- [x] Bulleted Lists
41-
- [x] Numbered Lists
42-
- [x] Links
43-
- [x] Columns
44-
- [x] iFrames
45-
- [x] Videos
46-
- [x] Divider
47-
- [x] Callout
48-
- [x] Image Captions
49-
- [x] Code Blocks
51+
In this example we use [Next.js](https://github.com/zeit/next.js) for SSG. We use [notionapi-agent](https://github.com/dragonman225/notionapi-agent) to fetch data from the API.
5052

51-
Missing
53+
To get your `pageId`, inspect network requests while visiting a public Notion page. It is included in the body of the `POST /api/v3/loadPageChunk` request.
5254

53-
- [ ] Checkboxes
54-
- [ ] Toggle Lists
55-
- [ ] Tables
55+
`/pages/my-post.jsx`
56+
57+
```js
58+
import "react-notion/src/styles.css";
59+
import "prismjs/themes/prism-tomorrow.css";
60+
import { NotionRenderer } from "react-notion";
61+
import { createAgent } from "notionapi-agent";
62+
63+
const agent = createAgent();
64+
65+
export async function getStaticProps() {
66+
const pageId = "2e22de6b-770e-4166-be30-1490f6ffd420"; // Your Notion Page ID
67+
const pageChunk = await agent.loadPageChunk({
68+
pageId,
69+
limit: 999,
70+
chunkNumber: 0,
71+
cursor: { stack: [] },
72+
verticalColumns: false
73+
});
74+
75+
return {
76+
props: {
77+
blockMap: pageChunk.recordMap.block
78+
}
79+
};
80+
}
81+
82+
export default ({ blockMap }) => (
83+
<div style={{ maxWidth: 768 }}>
84+
<NotionRenderer blockMap={blockMap} />
85+
</div>
86+
);
87+
```
5688

5789
## Sites using react-notion
5890

91+
List of pages that implement this library.
92+
5993
- [PS Tunnel](https://pstunnel.com/blog)
6094
- [Splitbee](https://splitbee.io/blog)
6195

96+
## Supported Blocks
97+
98+
Most common block types are supported. We happily accept new pull requests to add support for the missing blocks.
99+
100+
| Block Type | Supported | Notes |
101+
| ------------- | ---------- | ----------------- |
102+
| Text | ✅ Yes | |
103+
| Heading | ✅ Yes | |
104+
| Image | ✅ Yes | |
105+
| Image Caption | ✅ Yes | |
106+
| Bulleted List | ✅ Yes | |
107+
| Numbered List | ✅ Yes | |
108+
| Quote | ✅ Yes | |
109+
| Callout | ✅ Yes | |
110+
| Column | ✅ Yes | |
111+
| iframe | ✅ Yes | |
112+
| Video | ✅ Yes | Only embed videos |
113+
| Divider | ✅ Yes | |
114+
| Link | ✅ Yes | |
115+
| Code | ✅ Yes | |
116+
| Databases | ❌ Missing | |
117+
| Checkbox | ❌ Missing | |
118+
| Toggle List | ❌ Missing | |
119+
| Web Bookmark | ❌ Missing | |
120+
62121
## Credits
63122

64-
- [Timo Lins](https://timo.sh) – Helped building this package
123+
- [Tobias Lins](https://tobi.sh) – Idea, Code
124+
- [Timo Lins](https://timo.sh) – Code, Documentation
65125
- [samwightt](https://github.com/samwightt) – Inspiration & API Typings

0 commit comments

Comments
 (0)