Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-source-notion-article

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-source-notion-article

Gatsby source plugin to import articles made in Notion

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Gatsby Source Notion Article

CI codecovAll Contributors

A Gatsby source plugin for importing articles made in Notion into your Gatsby application using Notion API.

⚠️ The Notion API being still in beta, some limitations may exist. Feel free to open a discussion or ask for a new feature.

Install

# using npm
npm install gatsby-source-notion-article

# using yarn
yarn add gatsby-source-notion-article

How to configure

1. Create your integration

Create a new integration. It will give you access to a token that will be used in Gatsby Source Notion Article. Once it's created, copy your token and keep it for the next step.

2. Duplicate Notion database

Duplicate this article database template to ensure your articles follows the same format as this plugin. Don't forget to share this new database with the integration you just created.

3. Set your environment variables in a .env file

Create an .env file at the root of your Gatsby project. You can copy-paste the .env.example from this Github repository.

https://www.notion.so/myworkspace/a8aec43384f447ed84390e8e42c2e089?v=...
                                  |--------- Database ID --------|
NOTION_KEY=<your-notion-token>
NOTION_DATABASE_ID=<your-notion-database-id>

4. Add plugin to your gatsby config

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-source-notion-article`,
      options: {
        // Learn about environment variables: https://gatsby.dev/env-vars
        token: process.env.NOTION_KEY, // required
        databaseId: process.env.NOTION_DATABASE_ID, // required
        params: {
          page_size: 3, // optional, default is 100
          filter: {} // optional
          sort: {

          } // optional
        }
      }
    },
  ],
}

Options

NameTypeDefaultDescription
tokenstring[required] The token from Notion could be find on your integration
databaseIdstring[required] The databaseId is the alphanumerical value following the name of your workspace in the sharing URL.
paramsobjectThe params object
params.page_sizenumber100How many articles you want Notion to query
params.filterobjectAn object with filters passed to Notion
params.sortobjectAn option with sort options passed to Notion
debugbooleanfalseEnable the debug mode for Notion
unsupportedbooleanfalseShows in the body a message if the block is not supported. This can be enable only in development mode.

Type of blocks currently supported

The Notion API being in beta, only some block elements are currently supported:

  • Headings (1, 2, 3)
  • Paragraphs
  • Bullet and numbered list
  • To do
  • Toggle
  • Child page

How to query

Get all articles from your notion database

{
  allNotionArticles {
    edges {
      node {
        id
        title
        body
        createdAt
        updatedAt
      }
    }
  }
}

Get an article from your notion database

{
  notionArticles {
    id
    title
    body
    createdAt
    updatedAt
  }
}

Examples

Check our example project of the Gatsby plugin implementation.

// Quick example
const Component = {
  const data = useStaticQuery(graphql`
    query Notion {
      notionArticles {
        body
      }
    }
  `);

  return (
    <div dangerouslySetInnerHTML={{ __html: data.notionArticles.body }} />
  );
};

Contributing

If you've ever wanted to contribute to open source, and a great cause, now is your chance!

See the contributing docs for more information.

Feel free to open a discussion if you have any question or suggestion in regards to this plugin.

Contributors

Thanks goes to these wonderful people


David Dias

💻 📖 🚇 ⚠️

(emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

See MIT Licence, 2021 David Dias

Keywords

FAQs

Package last updated on 26 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc