Skip to content

Commit ffcd9f7

Browse files
author
Sergei Orlov
committed
📝 Add basic usage information
1 parent dc556a8 commit ffcd9f7

File tree

1 file changed

+97
-1
lines changed

1 file changed

+97
-1
lines changed

README.md

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,102 @@
77
Gatsby Source Plugin Notion API
88
</h1>
99

10+
[![Maintainability](https://api.codeclimate.com/v1/badges/669015699caf1728d984/maintainability)](https://codeclimate.com/github/orlowdev/gatsby-source-notion-api/maintainability)
11+
12+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
13+
[![versioning: or-release](https://img.shields.io/badge/versioning-%7C%7Cr-E76D83.svg)](https://github.com/orlowdev/or-release)
14+
1015
Gatsby source plugin for working with official [Notion](https://notion.so) API.
1116

12-
## 🚧 Work in progress
17+
## 🚧 It's a work in progress
18+
19+
This is a source plugin for pulling content into Gatsby from official public Notion API (currently
20+
in beta). With this plugin, you will be able to query your Notion pages in Gatsby using GraphQL.
21+
22+
[Notion API Reference](https://developers.notion.com/reference/intro)
23+
24+
An example (...coming soon)
25+
26+
## Install
27+
28+
```sh
29+
yarn add gatsby-source-notion-api
30+
```
31+
32+
or
33+
34+
```sh
35+
npm install --save gatsby-source-notion-api
36+
```
37+
38+
## How to use
39+
40+
Before using this plugin, make sure you
41+
42+
1. Created a Notion integration (sign in to Notion, go to `Settings & Memberships``Integrations`
43+
`Develop your own integrations`,
44+
[short link to the Integrations creation section](https://www.notion.so/my-integrations)). It's
45+
OK to use an internal one. Don't forget to copy the token.
46+
2. Go to the database you want to have access to and share it with the integration (`Share` → Select
47+
the integration in the `Invite` dropdown). Don't forget the database in the URL. It's a series of
48+
characters after the last slash and before the question mark. Here's a reference:
49+
https://www.notion.so/{USER}/**{DATABASE_ID}**?{someotherirrelevantstuff}
50+
3. Then add this to your `gatsby-config.json`:
51+
52+
```javascript
53+
plugins: [
54+
{
55+
resolve: `gatsby-source-notion-api`,
56+
options: {
57+
token: `$INTEGRATION_TOKEN`,
58+
databaseId: `$DATABASE_ID`,
59+
},
60+
},
61+
// ...
62+
]
63+
```
64+
65+
## Configuration options
66+
67+
`token` [string][required]
68+
69+
Integration token.
70+
71+
`databaseId` [string][required]
72+
73+
The identifier of the database you want to get pages from. The integration identified by provided
74+
token must have access to the database with given id.
75+
76+
## How to query for nodes
77+
78+
You can query for pages with `notion` or grab all of them with `allNotion`. The raw content of the
79+
page is available under `raw` property.
80+
81+
### Query for all nodes
82+
83+
```graphql
84+
query {
85+
allNotion {
86+
edges {
87+
node {
88+
raw
89+
}
90+
}
91+
}
92+
}
93+
```
94+
95+
## Current state
96+
97+
- Due to the fact that Notion API only appeared recently, and it is still in beta, some blocks are
98+
marked "unsupported". Among others, images cannot be fetched for now
99+
- Currently, `gatsby-source-notion-api` can only work with one provided database. In further
100+
releases, all databases reachable by the Integration will be available for querying
101+
- Nested blocks are currently skipped. E.g. if a list item has a nested sublist, it's contents will
102+
be omitted. This will be fixed in the nearest releases
103+
- Only raw content is available. Raw meaning whatever Notion returns. Further releases will aim at
104+
providing a more convenient data format apart from the raw one
105+
106+
## 🎉 You did it
107+
108+
Thanks for reaching to the end of the readme!

0 commit comments

Comments
 (0)