Skip to main content
DocunotionDocusaurusNPM

docu-notion

Docs / Blog workflow

GitHub Actions:

    "pulldocs": "cross-var docu-notion -n %DOCU_NOTION_INTEGRATION_TOKEN% -r %DOCU_NOTION_DOCS_PAGE% -t \\"*\\" -m \\"./docs\\"",
"pullblog": "cross-var docu-notion -n %DOCU_NOTION_INTEGRATION_TOKEN% -r %DOCU_NOTION_BLOG_PAGE% -t \\"*\\" -m \\"./blog\\""

  • A single Notion connection is used for the entire Workspace
  • The workspace includes a database and two root pages for documents and blog

  • To pull only the documents or blog structure, we use the page id of KB and Blog in the GitHub Action

  • We do not check the database status info of a page

  • We utilize the statuses to differentiate the pages between blog and documents

Modifications

We've introduced the Notion multiline string property Frontmatter.

The string is added to the notionFrontmatterProperties.

This way, we're able to use any Frontmatter in docu-notion

Below are the changes we implemented:

  • src/transform.ts

      if (page.frontmatter) {
    const notionFrontmatter = page.frontmatter;

    const notionFromtmatterProperties = notionFrontmatter.split("\\n");

    notionFromtmatterProperties.forEach(property => {
    frontmatter += `${property}\\n`;
    });
    }

  • src/NotionPage.ts

      public get frontmatter(): string | undefined {
    return this.getPlainTextProperty("Frontmatter", "");
    }

NPM

Overview

Updating process

# Install dependencies
npm i

# Update version number in docu-notion
# File: <https://github.com/JustInnIO/docu-notion/blob/main/package.json>

# Execute build
npm run build

# Sign In to NPMjs.com
npm adduser

# NPM Publish new version
npm publish

# Update the version number for the website
# File: <https://github.com/JustInnIO/website/blob/master/package.json>

Notion API Info

docu-notion utilizes docu-notion/src/pull.ts at main · sillsdev/docu-notion (github.com) to pull pages from Notion. The logic can be altered.

With the following function, we locate pages in Notion:

await notionClient.pages.retrieve({ page_id: options.rootPage });

The GET function is detailed here:

https://developers.notion.com/reference/retrieve-a-page

It is possible to add a filter property:

The filter is defined in the body.

Example

{
"and": [
{
"property": "Approved",
"checkbox": {
"equals": true
}
},
{
"property": "Episodes",
"select": {
"equals": "React"
}
}
]
}