# notion-to-mdx

> Generate markdown pages from notion

Latest version **0.1.2** (published 2023-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install notion-to-mdx
pnpm add notion-to-mdx
yarn add notion-to-mdx
bun add notion-to-mdx
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-04-28 |
| First published | 2023-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 54.3 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Feavy |
| Maintainers | feavy |

## Links

- npm: https://www.npmjs.com/package/notion-to-mdx
- Repository: https://github.com/Feavy/notion-to-mdx
- Homepage: https://github.com/Feavy/notion-to-mdx#readme
- Issues: https://github.com/Feavy/notion-to-mdx/issues
- npm.io page: https://npm.io/package/notion-to-mdx

## Dependencies (5)

- [react](https://npm.io/package/react.md) ^18.2.0
- [download](https://npm.io/package/download.md) ^8.0.0
- [image-size](https://npm.io/package/image-size.md) ^1.0.2
- [image-type](https://npm.io/package/image-type.md) 4.1.0
- [@notionhq/client](https://npm.io/package/@notionhq/client.md) ^2.2.4

## Recent versions

- 0.1.2 (latest) — 2023-04-28
- 0.1.1 — 2023-04-28
- 0.1.0 — 2023-04-27
- 0.0.2 — 2023-04-13
- 0.0.1 — 2023-04-13

## README

# notion-to-mdx [WIP]

[![npm version](https://badge.fury.io/js/notion-to-mdx.svg)](https://badge.fury.io/js/notion-to-mdx)

Generate MarkdownX articles from Notion pages.

This project aims to synchronize remote pages on Notion with local MarkdownX files:

- Each page found in a Notion database is converted into a MarkdownX file.
- Images are downloaded and stored locally.
- Links to Notion pages are replaced with links to the generated MarkdownX files.

It was mainly designed so that the generated files can be processed by the [mdx](https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/) plugin of [Gatsby](https://www.gatsbyjs.com/) to generate blog content. Of course, it can be used for any other purpose.

## Roadmap

- [x] Synchronize pages from a Notion database with MarkdownX files.
- [x] Download images and store them locally.
- [x] Replace links to Notion pages with links to the generated MarkdownX files.
- [ ] Default implementation for `TableOfContents`, `PageMention`, `LinkPreview`, etc.
- [ ] Notion source: wiki.
- [ ] Source: page.
- [ ] Support the `child_page` block.
- [ ] Documentation.
- [ ] Getting started.

## Usage

```js
import synchronizeNotionPages from "notion-to-mdx";

synchronizeNotionPages([
  {
    notionToken: "<your-notion-token>",
    type: "database",
    id: "<database-id>",
    outputDir: "./output/pages",
    basePath: "/pages"
  }
]);
```

## API

### `synchronizeNotionPages(sources: NotionSource[])`

Synchronizes Notion pages with MarkdownX files.

### `NotionSource`

```ts
interface NotionSource {
  notionToken: string;
  type: "database" | "page" | "wiki";
  id: string;
  outputDir: string;
  basePath: string;
}
```

---
_Source: https://npm.io/package/notion-to-mdx · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
