You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

gatsby-source-notion-api

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-notion-api

Gatsby source plugin for official Notion.so API

0.2.1
Source
npmnpm
Version published
Weekly downloads
158
-3.07%
Maintainers
1
Weekly downloads
 
Created
Source

Gatsby

Gatsby Source Plugin Notion API

Maintainability

code style: prettier versioning: or-release

Gatsby source plugin for working with official Notion API.

🚧 It's a work in progress

This is a source plugin for pulling content into Gatsby from official public Notion API (currently in beta). With this plugin, you will be able to query your Notion pages in Gatsby using GraphQL.

Notion API Reference

An example (...coming soon)

Install

yarn add gatsby-source-notion-api

or

npm install --save gatsby-source-notion-api

How to use

Before using this plugin, make sure you

  • Created a Notion integration (sign in to Notion, go to Settings & MembershipsIntegrationsDevelop your own integrations, short link to the Integrations creation section). It's OK to use an internal one. Don't forget to copy the token.
  • Go to the database you want to have access to and share it with the integration (Share → Select the integration in the Invite dropdown). Don't forget the database in the URL. It's a series of characters after the last slash and before the question mark. Here's a reference: https://www.notion.so/{USER}/**{DATABASE_ID}**?{someotherirrelevantstuff}
  • Then add this to your gatsby-config.json:
plugins: [
	{
		resolve: `gatsby-source-notion-api`,
		options: {
			token: `$INTEGRATION_TOKEN`,
			databaseId: `$DATABASE_ID`,
		},
	},
	// ...
]

Configuration options

token [string][required]

Integration token.

databaseId [string][required]

The identifier of the database you want to get pages from. The integration identified by provided token must have access to the database with given id.

How to query for nodes

You can query for pages with notion or grab all of them with allNotion. The raw content of the page is available under raw property.

Query for all nodes

query {
	allNotion {
		edges {
			node {
				raw
			}
		}
	}
}

Current state

  • Due to the fact that Notion API only appeared recently, and it is still in beta, some blocks are marked "unsupported". Among others, images cannot be fetched for now
  • Currently, gatsby-source-notion-api can only work with one provided database. In further releases, all databases reachable by the Integration will be available for querying
  • Nested blocks are currently skipped. E.g. if a list item has a nested sublist, it's contents will be omitted. This will be fixed in the nearest releases
  • Only raw content is available. Raw meaning whatever Notion returns. Further releases will aim at providing a more convenient data format apart from the raw one

🎉 You did it

Thanks for reaching to the end of the readme!

Keywords

gatsby

FAQs

Package last updated on 16 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts