{"id":15021387,"url":"https://github.com/wonism/gatsby-source-notion-contents","last_synced_at":"2025-04-09T19:50:46.199Z","repository":{"id":36762377,"uuid":"230115182","full_name":"wonism/gatsby-source-notion-contents","owner":"wonism","description":"Get gatsby sources from notion with `get-notion-contents`","archived":false,"fork":false,"pushed_at":"2023-01-06T02:23:00.000Z","size":2178,"stargazers_count":37,"open_issues_count":26,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T21:45:52.370Z","etag":null,"topics":["gatsby","gatsby-notion","gatsby-plugin","gatsby-plugins","gatsby-source","gatsby-source-plugin","gatsbyjs","notion"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wonism.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-25T14:39:14.000Z","updated_at":"2023-10-16T16:11:12.000Z","dependencies_parsed_at":"2023-01-17T04:36:14.570Z","dependency_job_id":null,"html_url":"https://github.com/wonism/gatsby-source-notion-contents","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fgatsby-source-notion-contents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fgatsby-source-notion-contents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fgatsby-source-notion-contents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wonism%2Fgatsby-source-notion-contents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wonism","download_url":"https://codeload.github.com/wonism/gatsby-source-notion-contents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809962,"owners_count":20999816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gatsby","gatsby-notion","gatsby-plugin","gatsby-plugins","gatsby-source","gatsby-source-plugin","gatsbyjs","notion"],"created_at":"2024-09-24T19:56:31.560Z","updated_at":"2025-04-09T19:50:46.169Z","avatar_url":"https://github.com/wonism.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/dQ3sAxl"],"categories":["JavaScript"],"sub_categories":[],"readme":"# gatsby-source-notion-contents\n\u003e Get gatsby sources from notion\n\n[![NPM](https://img.shields.io/npm/v/gatsby-source-notion-contents.svg?style=flat)](https://npmjs.org/package/gatsby-source-notion-contents)\n![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/gatsby-source-notion-contents.svg)\n\n## Installation\n```sh\n$ npm i -S gatsby-source-notion-contents\n```\n\n## ⚠️ Prerequisite\nYou need a token to use this package if you want to get private contents.\nYou can get it from [Notion.so](https://www.notion.so/) cookie. the key of it is `token_v2`.\n\n\n## Options\n```ts\ntype Option = {\n  token?: string; // Optional. need token when you need to get private contents.\n  ids?: string[]; // Optional. to get contents that are out of scope.\n  prefix?: string; // Optional. to add prefix into relative links.\n  removeStyle?: boolean; // Optional. to remove inline styles.\n};\n```\n\n__ids__\n\nIf the URL is `https://www.notion.so/Personal-Home-db45cd2e7c694c3493c97f2376ab184a`,\nYou need to add `db45cd2e7c694c3493c97f2376ab184a` into `options.ids`.\n\n## How to use\n```js\n// In your gatsby-config.js\n{\n  // other configs ...\n  plugins: [\n    // other plugins ...\n    {\n      resolve: `gatsby-source-notion-contents`,\n      options: {\n        token: '\u003c\u003cYOUR_NOTION_TOKEN\u003e\u003e',\n        ids: ['\u003c\u003cID_OF_NOTION_PAGE\u003e\u003e'],\n        prefix: '/',\n        removeStyle: false,\n      },\n    },\n  ]\n}\n```\n\n## How to query\n- Get all posts\n\n```graphql\nquery Notions {\n  allNotionContent {\n    edges {\n      node {\n        id\n        contentType\n        internal {\n          # ... other properties of internal\n          content\n        }\n      }\n    }\n  }\n}\n```\n\n- Get a post\n\n```graphql\nquery Notion {\n  notionContent {\n    id\n    contentType\n    internal {\n      # ... other properties of internal\n      content\n    }\n  }\n}\n```\n\n- Get a specific post\n\n```graphql\nquery Notion {\n  notionContent(id: { eq: \"ID_SPECIFIC_POST\" }) {\n    id\n    contentType\n    internal {\n      # ... other properties of internal\n      content\n    }\n  }\n}\n```\n\n## Example\n\n#### Sample project\n- https://github.com/wonism/gatsby-source-notion-contents-sample\n\n#### Example source\n```jsx\nconst Component = {\n  const data = useStaticQuery(graphql`\n    query Notion {\n      notionContent {\n        internal {\n          content\n        }\n      }\n    }\n  `);\n\n  return (\n    \u003cdiv dangerouslySetInnerHTML={{ __html: data.notionContent.internal.content }} /\u003e\n  );\n};\n```\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.buymeacoffee.com/dQ3sAxl\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" width=\"217\" height=\"51\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fgatsby-source-notion-contents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwonism%2Fgatsby-source-notion-contents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwonism%2Fgatsby-source-notion-contents/lists"}