Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/narkdown/narkdown-py
A tool to use Notion as a Markdown editor.
https://github.com/narkdown/narkdown-py
cms notion
Last synced: about 2 months ago
JSON representation
A tool to use Notion as a Markdown editor.
- Host: GitHub
- URL: https://github.com/narkdown/narkdown-py
- Owner: narkdown
- License: mit
- Archived: true
- Created: 2020-09-14T14:55:11.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-28T02:33:19.000Z (over 3 years ago)
- Last Synced: 2024-10-12T14:43:38.831Z (2 months ago)
- Topics: cms, notion
- Language: Python
- Homepage: https://narkdown.notion.site/Narkdown-en-6eeb0ce1872d4098abca86a30cb29ab4
- Size: 4.35 MB
- Stars: 41
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Narkdown
| [English](/README.md) | [한국어](/docs/README.ko.md) |
**A tool to use Notion as a Markdown editor.**
---
> ⚠️ **NOTE:** Narkdown is dependent on [notion-py](https://github.com/jamalex/notion-py), the **_unofficial_** Notion API created by [Jamie Alexandre](https://github.com/jamalex). It can not gurantee it will stay stable. If you need to use in production, I recommend waiting for their official release.
---
## Installation
```bash
pip install narkdown
# pip3 install narkdown
```## Usage
> ⚠️ **NOTE:** the latest version of narkdown requires Python 3.5 or greater.
### Quick Start
#### CLI
![narkdown-image-0](docs/images/readme-image-0.png)
[How To Find Your Notion v2 Token - Red Gregory](https://www.redgregory.com/notion/2020/6/15/9zuzav95gwzwewdu1dspweqbv481s5)
#### Python
[`example.py`](https://github.com/younho9/narkdown/blob/main/example.py)
![narkdown-image-1](docs/images/readme-image-1.png)
```bash
python3 example.py
```#### Database template page for test
Here is an [database template page](https://www.notion.so/acc3dfd0339e4cacb5baae8673fddfad?v=be43c1c8dd644cfb9df9efd97d8af60a) for importing pages from the database. Move to that page, duplicate it, and test it.
## Features
- **Import page from Notion and save it to the desired path.**
- **Import database from Notion and save pages to the desired path.**
- Useful for CMS(Contents Manage System) of static pages such as blog or docs page.
- Support import by status of content.
- Support filter contents.
- **Import** **_child page_** **in Notion page recursively. And import** **_linked page_** **as a Notion page link.**
- **Support nested block. (e.g. bulleted, numbered, to-do, toggle)**
- **Support language selection of code block.**
## Configuring Narkdown
Narkdown provides some configuration for how to extract documents. You can configure Narkdown via `narkdown.config.json` .
Create `narkdown.config.json` and run `python3 -m narkdown` in that directory.
```json
// narkdown.config.json
{
"exportConfig": {
"recursiveExport": true,
"createPageDirectory": true,
"addMetadata": true,
"appendCreatedTime": true,
"generateSlug": true
},
"databaseConfig": {
"categoryColumnName": "Category",
"statusColumnName": "Status",
"currentStatus": "✅ Completed",
"nextStatus": "🖨 Published"
}
}
```
| Name | Description | Default |
| --------------------- | ------------------------------------------------------------------------------------------------- | --------- |
| `recursiveExport` | Whether or not to recursively export child page. | [`true`] |
| `createPageDirectory` | Whether or not to create subdirectories with page titles for each page. | [`true`] |
| `addMetadata` | Whether or not to add metadata to content. | [`false`] |
| `appendCreatedTime` | Whether or not to append created time to filename. ( The page must have a created time property.) | [`false`] |
| `generateSlug` | Whether or not to generate and append slug to metatdata. | [`false`] |
| Name | Description | Default |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `categoryColumnName` | In Notion database, content can be classified by category by `select` property. When you create the `select` property in the Notion database and pass the name of the column, folders are created by category. | [`""`] |
| `statusColumnName` | In the Notion database, you can manage the status of content with `Select` property. If you create a `Select` property in the Notion database and pass the name of the column, you can import contents in a specific state or change the status of the content. (should be used with the `currentStatus` or `nextStatus` option.) | [`""`] |
| `currentStatus` | Import only the content that corresponds to `currentStatus` value. ( `statusColumnName` must be set.) | [`""`] |
| `nextStatus` | Changes content status to `nextStatus` value after import. ( `statusColumnName` must be set.) | [`""`] |#### Set env variable for `token_v2`
The `token_v2` of notion is a variable that should not be shared. You can use os environment variable for notion token.
Narkdown use the `NOTION_TOKEN` as an environment variable for `token_v2`. Setting this environment variable allow the CLI to omit `token_v2` input.
## Advanced
### [Notion2Github](https://github.com/younho9/notion2github) `recommended`
Github action to synchronize the content of the notion database with github.
## Supported Blocks
| Block Type | Supported | Notes |
| -------------------- | --------- | ----------------------------------------------------------------------------------------------- |
| Heading 1 | ✅ Yes | [Converted to heading 2 in markdown.](https://www.notion.so//11acfd542ee84640b3fb1782ce9b8caa) |
| Heading 2 | ✅ Yes | [Converted to heading 3 in markdown.](https://www.notion.so//11acfd542ee84640b3fb1782ce9b8caa) |
| Heading 3 | ✅ Yes | [Converted to heading 4 in markdown.](https://www.notion.so//11acfd542ee84640b3fb1782ce9b8caa) |
| Text | ✅ Yes | |
| Divider | ✅ Yes | Divider after the Heading 1 is not added. |
| Callout | ✅ Yes | Callout block will be exported as quote block with emoji. |
| Quote | ✅ Yes | |
| Bulleted list | ✅ Yes | Support nested block. |
| Numbered list | ✅ Yes | Support nested block. |
| To-do list | ✅ Yes | Support nested block. |
| Toggle list | ✅ Yes | Support nested block. |
| Code | ✅ Yes | Support syntax highlighting. |
| Image | ✅ Yes | Uploaded image will be downloaded to local. Linked image will be linked not be downloaded. |
| Web bookmark | ✅ Yes | Same as link text. |
| Page | ✅ Yes | Import "Child page" in Notion page recursively. And import "Linked page" as a Notion page link. |
| Table (aka database) | ✅ Yes | |
| Video | ❌ No | |
| Audio | ❌ No | |
| File | ❌ No | |
| Embed other services | ❌ No | |
| Advanced | ❌ No | |
| Layout in page | ❌ No | |### License
MIT © [younho9](https://github.com/younho9)