Download Notion pages as markdown and image files, preserving hierarchy and enabling workflow properties. Works with Docusaurus.

Overview

notion-pull

notion-pull lets you use Notion as your editor for markdown-based static site generators like Docusaurus. Using Notion instead of raw markdown files means that you don't have to teach non-developers how to make git commits and pull requests. It also allows you to leverage Notion's database tools to control workflow, Notion's commenting feature to discuss changes, etc.

Example Site: https://sillsdev.github.io/notion-pull-sample-site/

Instructions

1. Set up your documentation site.

First, prepare your markdown-based static file system like Docusaurus. For a shortcut with github actions, search, and deployment to github pages, you can just copy this template.

2. In Notion, duplicate the notion-pull template

Go to this template page. Duplicate it into your own workspace. You can name it anything you like, e.g. "Documentation Root".

3. Create a Notion Integration

In order for notion-pull to read your site via Notion's API, you need to create what Notion calls an "integration". Follow these instructions to make an integration and get your token. Limit your integration to "READ" access.

4. "Invite" your Notion Integration to read you page

In Notion, click "Share" on the root of your documentation and "invite" your integration to it.

image

5. Add your pages under your Outline page.

Currently, notion-pull expects that each page has only one of the following: subpages, links to other pages, or normal content. Do not mix them. You can add content pages directly here, but then you won't be able to make use of the workflow features. If those matter to you, instead make new pages under the "Database" and then link to them in your outline pages.

6. Pull your pages

First, determine the id of your root page by clicking "Share" and looking at the the url it gives you. E.g. https://www.notion.so/hattonjohn/My-Docs-0456aa5842946bdbea3a4f37c97a0e5 means that the id is "0456aa5842946PRETEND4f37c97a0e5".

Determine where you want the markdown files and images to land. The following works well for Docusaurus instances:

npx notion-pull -n secret_PRETEND123456789PRETEND123456789PRETEND6789 -r 0456aa5842946PRETEND4f37c97a0e5 -m "./docs" -i "./images"

Likely, you will want to store these codes in your environment variables and then use them like this:

(windows)
npx notion-pull -n %MY_NOTION_TOKEN% -r %MY_NOTION_DOCS_ROOT_PAGE_ID% -m "./docs" -i "./static/notion_images" -p "/notion_images/"
(linux / mac)
npx notion-pull -n $MY_NOTION_TOKEN -r $MY_NOTION_DOCS_ROOT_PAGE_ID -m "./docs" -i "./static/notion_images" -p "/notion_images/"

7. Commit

Most projects should probably commit the current markdown and image files each time you run notion-pull.

Note that if you choose not to commit, the workflow feature (see below) won't work for you. Imagine the case where a document that previously had a Status property of Publish now has a different status. You probably want to keep publishing the old version until the new one is ready. But if you don't commit files, your CI system (e.g. Github Actions) won't have the old version around, so it will disappear from your site.

Advanced: using a Notion database for workflow

One of the big attractions of Notion for large documentation projects is that you can treat your pages as database items. The advantage of this is that they can then have metadata properties that fit your workflow. For example, we use a simple kanban board view to see where each page is in our workflow:

image

notion-pull supports this by letting you link to database pages from your outline.

image

Known Limitations

notion-pull is not doing anything smart with regards to previously Published but now not Published documents. All it does is ignore every Notion document that doesn't have status == Publish. So if the old version of the document is still in your file tree when your static site generator (e.g. Docusaurus) runs, then it will appear on your website. If it isn't there, it won't. If you rename directories or move the document, notion-pull will not realize this and will delete the previously published markdown file.

Links from one document to another in Notion are not yet converted to local links.

Notion-pull makes some attempt to keep the right order of things, but there are definitely cases where it isn't smart enough yet.

Localization

Localize your files in Crowdin (or whatever) based on the markdown files, not in Notion. For how to do this with Docusaurus, see Docusaurus i18n.

Automated builds with Github Actions

Here is a working Github Action script to copy and customize: https://github.com/BloomBooks/bloom-docs/blob/master/.github/workflows/release.yml

Comments
  • Enhancement request: Link to a specific heading in a document

    Enhancement request: Link to a specific heading in a document

    At present links to documents are supported but only to the whole document. It would be nice to link to a specific heading either in the same document or another document.

    How to do it in Docusaurus Docusaurus allows this by adding a code to the (destination) heading {#...} and then including that code in the link. For example, see https://manual.paratext.org/Training-Manual/Stage-1/OD

    In chapter 2 under 2.3 Create a new text layout I have a link to section 2.5 ... ≡ Paratext menu, under (Paratext > Open, select several resources, choose to open as Text collection. See [2.5]

    Heading 2.5 is coded as: ### 2.5 Open resources in a Text collection {#25} The link is coded as: See [2.5] (/Training-Manual/02-Stage-1/2.OD.md#25) (the link is broken to display the coding)

    Note: I have the code without decimal points otherwise it didn't work reliably.

    Docusaurus documentation see https://docusaurus.io/docs/markdown-features/toc#example-subsubsection-1-a-ii for a discussion on setting an explicit heading id.

    released 
    opened by JenniBeadle 6
  • Links to document open the Notion file not the MD file.

    Links to document open the Notion file not the MD file.

    Describe the bug What is the best way to add links?
    If I add the link in Notion then when I click on the link it takes me to the Notion file not the webpage. I have many links in my project which worked well in raw MD files but my conversion process (Word add-in) has hard-coded them to a file on my c: drive so I need to replace them.

    ** Reproduction Steps ** Goto https://sillsdev.github.io/paratext-manual/Overview/ Click on link to the right of the chapter name (e.g. 1.Intro) The notion page opens.

    URL of a source Notion page that, when docu-notion accesses or converts it, shows the problem: https://jennibeadle.notion.site/00-Overview-3ce84f9ca3264aed8532489c0574f95c (see links in Introduction)

    At least one of these:

    1. URL of a docusuarus site showing the resulting page https://sillsdev.github.io/paratext-manual/Overview/ (see links in Introduction)

    Expected behavior When I click on the link on a page I expect to go to the appropriate page on the website. So if I clicked on 1.Intro I expect to go to https://sillsdev.github.io/paratext-manual/288f2a75-e689-4ec7-98f8-17f982c15e17/ not the Notion page.

    Screenshots If applicable, add screenshots to help explain your problem.

    Choose the link image

    Expected result image

    Actual result image

    Additional context Add any other context about the problem here.

    opened by JenniBeadle 5
  • Enhancement request: Generate _category_.json/yml files for names of sidebar dropdown items

    Enhancement request: Generate _category_.json/yml files for names of sidebar dropdown items

    Describe the issue Docusaurus uses the folder names (short with hyphens) for the sidebar dropdowns unless you add category.yml files to each folder to specify the name of the folder. These are also used to translate the folder names.

    See discussion on Category item metadata in https://docusaurus.io/docs/sidebar/autogenerated#category-item-metadata

    opened by JenniBeadle 5
  • Title in front matter not exported - uses filename instead

    Title in front matter not exported - uses filename instead

    Describe the bug Docu-notion doesn't output all the front matter to MD. The top of page heading "Notion title" is used as the filename and title. The front matter has a separate title field but the export replaces whatever is in that field with the top of page heading. My goal is a short filename (for URL) with a longer title (for sidebar).

    Reproduction Steps

    URL of a source Notion page that, when docu-notion accesses or converts it, shows the problem: https://jennibeadle.notion.site/0-0-3-4eed40af381f4fb8b455246b3bae0c7c

    At least one of these:

    1. URL of a docusuarus site showing the resulting page Desired result: https://manual.paratext.org/Video-summaries/Introduction/0.2.Navigation/0.0.3 Notion result: https://sillsdev.github.io/paratext-manual/4eed40af-381f-4fb8-b455-246b3bae0c7c/ (note title displayed was copied to the document for later editing)

    Expected behavior The text in the title field of Notion document front matter, will replace the Notion document "title".

    Screenshots If applicable, add screenshots to help explain your problem. Desired result image

    In Notion (showing front matter) image

    Docu-Notion website (showing short title not title from frontmatter) (Note the ---title ... was copied to add after next process) image

    Additional context Unfortunately, the Actions don't give me a file that I can tweak.

    enhancement 
    opened by JenniBeadle 5
  • feat: #30 Allow for variable-width columns and more than two columns

    feat: #30 Allow for variable-width columns and more than two columns

    This change is Reviewable

    BREAKING CHANGE: Makes changes to the expected css for formatting columns. So clients must make those changes to their respective css files to get the desired results.

    opened by andrew-polk 2
  • fix: Handle simple numbered lists

    fix: Handle simple numbered lists

    This works around a bug in notion-to-md and allows us to handle simple numbered lists. It will not handle lists that are continued after other content.

    released 
    opened by JohnThomson 2
  • Generate sidebar file in order to preserve Notion Outline ordering

    Generate sidebar file in order to preserve Notion Outline ordering

    If you use Docusaurus's auto-generated sidebar, it orders categories alphabetically:

    Notion: image

    Docusaurus site: image

    So while we currently get the order of individual pages correct (using sidebar_position), we don't have a way of also controlling the order of the categories .

    If docu-notion could generate the sidebar itself, then sites could use that to match the order of categories in the Notion source outline.

    enhancement released 
    opened by hatton 2
  • Text in lists can break mdx parser, should be escaped for html safety

    Text in lists can break mdx parser, should be escaped for html safety

    image

    docu-notion makes this into

     <li parentName="ol"><strong parentName="li">{`Dropbox`}</strong>{` will ask whether you want to “Remove `}<book title>{` from your Dropbox account and all devices?” Click “Move out of Dropbox”. If you do not want to see such notices in the future, you can tick the box “Don’t ask me this again”.`}</li>
    

    Instead, the text should be encoded so that it doesn't mess up the html parser. Q: what if there is content in there that we do want to be parsed?

    bug released 
    opened by hatton 1
  • Sidebar labels should not have dashes

    Sidebar labels should not have dashes

    The generated side bar is showing dashes in place of spaces from the page titles on Outline pages:

    image

    Actual documentation pages are fine:

    image

    www.notion.so/hattonjohn/docs-bloomlibrary-org-043c6aa5842946bdbea3a4f37c97a0e7 https://docs.bloomlibrary.org/

    bug released 
    opened by hatton 1
  • Support Docusaurus Admonitions

    Support Docusaurus Admonitions

    Notion has Callouts, and you can set the icon of them. But there is no way to set the color.

    Let's map 5 of these icons to their equivalent Docusaurus Admonitions.

    Then you can make a callout, set its icon, and get the fully styled admonition equivalent.

    enhancement 
    opened by hatton 1
  • Only (re)Publish if the Status is

    Only (re)Publish if the Status is "Publish"

    We should leave the previous version of the document in place if the current version has a Status that is not Publish.

    This will require not deleting the destination docs directory, and that will require that we notice what documents are no longer in Notion at all, so that we can delete them.

    enhancement 
    opened by hatton 1
  • Search only works on front page

    Search only works on front page

    Describe the bug The search add-in only finds results when used from the front page (intro page with slug /) and only hits on that page.

    ** Reproduction Steps **

    • Go to the intro page

    • Click in the search box

    • Type a word

      • only finds words on that page.
    • Go to another page

    • Click in the search box

    • Start to type a word

    • No results error

    URL of a source Notion page that, when docu-notion accesses or converts it, shows the problem:

    URL of a docusuarus site showing the resulting page https://sillsdev.github.io/paratext-manual/00-list-of-features/

    Expected behavior Expect to get results from all the pages.

    Screenshots Screenshot shows no result even when several results clearly seen on page image

    Additional context I checked the docusaurus.config.js and removed the comment on languages for the plug-in. It looks identical to my other working site.

    opened by JenniBeadle 2
  • Links don't work in numbered lists or callouts

    Links don't work in numbered lists or callouts

    Describe the bug Links in either numbered lists or callouts are not converted by docu-notion.

    Reproduction Steps In Notion

    • Create a numbered list block
    • Insert a link (to a https address)
      • Link is displayed in Notion

    Do a Release

    • Result has no link

    URL of a source Notion page that, when docu-notion accesses or converts it, shows the problem: https://jennibeadle.notion.site/5-BC1-Basic-checks-9a9d6657a78c4dacaaae3a1af028df41 (See just before 5.2 - I tested :::tip ...:::, callout, numbered list, and quote)

    URL of a docusuarus site showing the resulting page https://sillsdev.github.io/paratext-manual/05.BC1/

    Expected behavior Obviously, I expect to have a link to click on (as shown in Notion)

    Screenshots Various blocks Admonitions - Markdown works, quote works but callout and numbered list don't convert. image

    Manually Numbered lists work Appendix is a text block with manual numbered and works. image

    opened by JenniBeadle 0
  • Numbered lists don't continue

    Numbered lists don't continue

    Describe the bug Numbered lists restart at 1 after subheading even when given a specific starting number after the heading. Having just looked at the Notion markdown, I think it may be a Notion bug not a docu-notion bug.

    Reproduction Steps I have 25 chapters in my Paratext Manual. In the overview I break them up into sections but need the sequential numbering to continue so it shows correct chapter number. Add a numbered list with headings. Edit each list item after the heading with the number to continue. Notion displays correctly. But the resulting page restarts the numbering.

    URL of a source Notion page that, when docu-notion accesses or converts it, shows the problem: Notion: https://jennibeadle.notion.site/Overview-of-Training-Manual-3ce84f9ca3264aed8532489c0574f95c Resulting page: https://sillsdev.github.io/paratext-manual/Overview/

    Expected behavior Numbering should continue (as per my other Docusaurus site. https://manual.paratext.org/Training-Manual/Overview

    Notion markdown The notion markdown still has 1.

    ### Stage 1 Drafting
    
    1. 2. **[OD** – Organising your desktop](https://sillsdev.github.io/paratext-manual/2.OD)
    2. **[PP1** – Project plan and progress](https://sillsdev.github.io/paratext-manual/3.PP1)
    

    I added the 2. to specify to continue from 2 but it still has the 1. I corrected the markdown and pasted it again but it added the 1. again.

    Screenshots In Notion: showing the continuer set image

    Result of Docu-notion (showing restart as 1): image

    Site using Markdown (sequential): image

    Additional context I searched for possible solutions. https://stackoverflow.com/questions/18088955/markdown-continue-numbered-list/22138846#22138846 suggested putting a blank link before the element (in their case a code block) but had no effect.

    opened by JenniBeadle 4
  • Support Notion Synced Blocks

    Support Notion Synced Blocks

    Describe the bug Synced blocks that are linked to the original are not rendered. The original synced block is rendered.

    ** Reproduction Steps **

    https://www.notion.so/metapages/Facts-mermaid-63f6f281a33649cc9dfabb86d26ad829

    The first mermaid diagram is not a synced block, and renders fine.

    The second block is a synced block, and renders fine in this page, but another page has a linked to that synced mermaid block:

    https://www.notion.so/metapages/Introduction-to-docu-notion-779f83504bd94642a9b87b2afc810a97

    Expected behavior Linked synced blocks show the exact contents of the original synced block

    Screenshots If applicable, add screenshots to help explain your problem.

    Additional context Add any other context about the problem here.

    enhancement 
    opened by dionjwa 0
  • Internal mermaid clickable links

    Internal mermaid clickable links

    Fixes #28

    I use mermaid diagrams with clickable link to other notion documents:

    image

    You can click on "An internal page" and it takes you to another notion document.

    This PR adds some config and processing to get those internal mermaid URLs working with docu-saurus.

    I tried to make a CodeTransformer in the same pattern as the other transformers, but it didn't have the right context for getting the links path to the notion documents, so I just added a link processor.

    The result is the same mermaid diagrams but the links correctly link to docusaurus pages:

    image

    You can then click the first node and you go to another page.

    There is an extra config flag, I was not able to figure out how to align the different docusaurus root documents you can specify (e.g. ./docs, ./blog), with the docu-notion->saurus step, so some experimentation may be needed to align the paths and the slugs.


    This change is Reviewable

    opened by dionjwa 3
  • [Feature] Variable column width in PDF output

    [Feature] Variable column width in PDF output

    Background Side-by-side presentations of text and images are more effective in training presentation contexts. The texts accompanying images frequently require less vertical space than the images.

    Problem

    • Images in columns that are not equal-width are rendered full-width in PDF output. (Images in one of two equal-width columns are rendered properly.)

    Desired behavior Respect the column widths specified in the Notion authoring environment in PDF output.

    Screenshots Notion editing environment: Columns editing PDF output: no columns

    opened by fraserbennett 0
Releases(v0.8.1)
Owner
SIL LSDev
SIL's Language Software Development
SIL LSDev
A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON.

notion-fetch A Cloudflare Workers service that fetches and renders Notion pages as HTML, Markdown, or JSON. Powered by Durable Objects and R2. Usage P

Heyang Zhou 7 Jan 6, 2023
A Docusaurus website deployed to GitHub Pages using GitHub Actions.

Deploy Docusaurus website to GitHub Pages using GitHub Actions This repository is an example of deploying a Docusaurus website to GitHub Pages using G

Lars Gyrup Brink Nielsen 18 Dec 26, 2022
This Next.js app replicates the WordPress Template Hierarchy, but in JavaScript

Next.js WordPress Template Hierarchy Routing This Next.js app replicates the WordPress Template Hierarchy, but in JavaScript! Requirements WordPress P

Blake Wilson 2 Oct 31, 2022
A GitHub app to report failed workflow job actions and notify pull request creator with custom report message for the failed workflow job.

Workflow Reporter A GitHub App built with Probot that reports failed workflow job actions and notify the pull request creator with custom report messa

Divyanshu Shekhar 14 Nov 12, 2022
Workflow to re-trigger workflow of all open PRs when base updates

Workflow to re-trigger workflow of all open PRs when base updates

James Tan 4 Aug 28, 2022
A Javascript library that discourages and prevents image theft/download by preventing client ability to retrieve the image.

ProtectImage.js ProtectImage.js is a Javascript library that helps prevent image theft by disabling traditional user interactions to download/copy ima

null 4 Aug 18, 2022
generate pages from markdown files with dynamic routes, 0 effort, 0 boilerplate.

next-markdown Markdown Pages for Next.js Dynamic Routes. Blog Aware. Design Your Layout Made for people having a nextjs project in ❤️ with markdown wh

François Rouault 105 Oct 11, 2022
Download all Moodle files with one click. This is a Chrome extension built to save time and effort from downloading files manually one by one!

Moodle Downloader Extension Moodle downloader extension for Chrome. The extension is tested with both the TUM moodle and the official moodle demo. Not

Zhongpin Wang 8 Nov 15, 2022
Markdown Transformer. Transform markdown files to different formats

Mdtx Inspired by generative programming and weed :). So I was learning Elm language at home usually in the evening and now I am missing all this gener

Aexol 13 Jan 2, 2023
Sync pages from Notion to GitHub to be used as a static website (JAM)

notion-jam Sync pages from Notion to GitHub to be used as a static website (JAM) Usage Quick Start Create a new Notion Integration Add Notion secret t

Victor 9 Nov 15, 2022
Show floating sticky outline (table of contents) for Notion pages, powered by nbundle.

Notion Outline Show floating sticky outline (table of contents) for Notion pages, powered by nbundle. This is an nbundle-powered Notion app bootstrapp

nbundle 11 Nov 10, 2022
A CloudFlare Worker / script / bot to sync Notion pages publicly as GitHub Discussions.

notion-github-sync This bot syncs public Notion pages as GitHub Discussions/Issues. It's done periodically, based on the pages shared with the Notion

The Guild 20 Dec 22, 2022
Contented is a Markdown-based authoring workflow that encourage developer authoring within its contextual Git repository.

Contented is a Markdown-based authoring workflow that encourage developer authoring within its contextual Git repository. npm i @birthdayresearch/cont

Birthday Research 44 Jan 7, 2023
Dyte's documentation portal built with Docusaurus.

Dyte Docs Dyte's documentation portal, built with Docusaurus. Explore the docs » View Demo · Report Bug · Request Feature Table of Contents About the

Dyte 70 Jan 1, 2023
DecentraMix.io is a cross-chain, non-custodial, universal privacy-preserving protocol with the decentralized governance

DecentraMix.io is a cross-chain, non-custodial, universal privacy-preserving protocol with the decentralized governance. DecentraWorld applies zkSNARKs to enable transactional privacy for all DeFi components by breaking the on-chain link between depositor and recipient addresses.

DecentraWorld Ecosystem 65 May 7, 2022
Dapp example for airdropping ERC-20 tokens using World ID, preserving privacy for the claimers with zero-knowledge proofs.

World ID Example - Mesha Airdrop This repository contains an example decentralized application (dapp) for World ID. With Mesha Airdrop test airdroppin

Worldcoin 14 Dec 16, 2022
Privacy preserving governance mechanism using zero knowledge for proof of merkle inclusion.

Zero Knowledge Private Voting V1 Motivation On-chain governance today is fully transparent at the cost of privacy. This means that every proposal and

Blockchain Capital 18 Dec 16, 2022
Privacy preserving governance mechanism using zero knowledge for proof of merkle inclusion.

Zero Knowledge Private Voting V1 Motivation On-chain governance today is fully transparent at the cost of privacy. This means that every proposal and

Blockchain Capital 11 Jun 7, 2022
optimize image & upload file to cloud as image bed with tiny image automic.

Rush! 图片压缩 & 直传图床工具 这是一个兴趣使然的项目, 希望 Rush! 能让这个世界的网络资源浪费减少一点点 下载 Downloads 获取最新发行版 功能 Features 拖拽批量压缩图片, 支持格式 jpg/png/gif Drop to optimize, jpg/png/gif

{ Chao } 3 Nov 12, 2022