Skip to content

Commit 6dee14b

Browse files
committed
fix: Name Change
1 parent 74770bf commit 6dee14b

File tree

9 files changed

+6372
-6494
lines changed

9 files changed

+6372
-6494
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
# notion-pull-mdx
1+
# docu-notion
22

3-
notion-pull-mdx lets you use Notion as your editor for markdown-based static site generators like [Docusaurus](https://docusaurus.io/). 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.
3+
docu-notion lets you use Notion as your editor for [Docusaurus](https://docusaurus.io/). 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.
44

5-
Example Site: https://sillsdev.github.io/notion-pull-mdx-sample-site/
5+
Example Site: https://sillsdev.github.io/docu-notion-sample-site/
66

77
# Instructions
88

99
## 1. Set up your documentation site.
1010

11-
First, prepare your markdown-based static file system like [Docusaurus](https://docusaurus.io/). For a shortcut with github actions, search, and deployment to github pages, you can just copy [this template](https://github.com/sillsdev/notion-pull-mdx-sample-site).
11+
First, prepare your markdown-based static file system like [Docusaurus](https://docusaurus.io/). For a shortcut with github actions, search, and deployment to github pages, you can just copy [this template](https://github.com/sillsdev/docu-notion-sample-site).
1212

13-
## 2. In Notion, duplicate the notion-pull-mdx template
13+
## 2. In Notion, duplicate the docu-notion template
1414

1515
Go to [this template page](https://hattonjohn.notion.site/Documentation-Template-Docusaurus-0e998b32da3c47edad0f62a25b49818c). Duplicate it into your own workspace.
1616
You can name it anything you like, e.g. "Documentation Root".
1717

1818
## 3. Create a Notion Integration
1919

20-
In order for notion-pull-mdx to read your site via Notion's API, you need to create what Notion calls an "integration". Follow [these instructions](https://developers.notion.com/docs/getting-started) to make an integration and get your token. Limit your integration to "READ" access.
20+
In order for docu-notion to read your site via Notion's API, you need to create what Notion calls an "integration". Follow [these instructions](https://developers.notion.com/docs/getting-started) to make an integration and get your token. Limit your integration to "READ" access.
2121

2222
## 4. "Invite" your Notion Integration to read you page
2323

@@ -27,7 +27,7 @@ In Notion, click "Share" on the root of your documentation and "invite" your int
2727

2828
## 5. Add your pages under your Outline page.
2929

30-
Currently, notion-pull-mdx 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.
30+
Currently, docu-notion 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.
3131

3232
## 6. Pull your pages
3333

@@ -38,34 +38,34 @@ means that the id is "0456aa5842946PRETEND4f37c97a0e5".
3838
Determine where you want the markdown files and images to land. The following works well for Docusaurus instances:
3939

4040
```
41-
npx notion-pull-mdx -n secret_PRETEND123456789PRETEND123456789PRETEND6789 -r 0456aa5842946PRETEND4f37c97a0e5"
41+
npx docu-notion -n secret_PRETEND123456789PRETEND123456789PRETEND6789 -r 0456aa5842946PRETEND4f37c97a0e5"
4242
```
4343

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

4646
```
4747
(windows)
48-
npx notion-pull-mdx -n %MY_NOTION_TOKEN% -r %MY_NOTION_DOCS_ROOT_PAGE_ID%
48+
npx docu-notion -n %MY_NOTION_TOKEN% -r %MY_NOTION_DOCS_ROOT_PAGE_ID%
4949
```
5050

5151
```
5252
(linux / mac)
53-
npx notion-pull-mdx -n $MY_NOTION_TOKEN -r $MY_NOTION_DOCS_ROOT_PAGE_ID
53+
npx docu-notion -n $MY_NOTION_TOKEN -r $MY_NOTION_DOCS_ROOT_PAGE_ID
5454
```
5555

56-
NOTE: In the above, we are using `npx` to use the latest `notion-pull-mdx`. A more conservative approach would be to `npm i cross-var notion-pull-mdx` and then create a script in your package.json like this:
56+
NOTE: In the above, we are using `npx` to use the latest `docu-notion`. A more conservative approach would be to `npm i cross-var docu-notion` and then create a script in your package.json like this:
5757

5858
```
5959
"scripts": {
60-
"pull": "cross-var notion-pull-mdx -n %NOTION_PULL_INTEGRATION_TOKEN% -r %NOTION_PULL_ROOT_PAGE%"
60+
"pull": "cross-var docu-notion -n %NOTION_PULL_INTEGRATION_TOKEN% -r %NOTION_PULL_ROOT_PAGE%"
6161
}
6262
```
6363

6464
and then run that with `npm run pull`.
6565

6666
## 7. Commit
6767

68-
Most projects should probably commit the current markdown and image files each time you run notion-pull-mdx.
68+
Most projects should probably commit the current markdown and image files each time you run docu-notion.
6969

7070
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.
7171

@@ -75,27 +75,27 @@ One of the big attractions of Notion for large documentation projects is that yo
7575

7676
![image](https://user-images.githubusercontent.com/8448/168929745-e6529375-bb1e-47e9-b8a6-7a1467c8900f.png)
7777

78-
`notion-pull-mdx` supports this by letting you link to database pages from your outline.
78+
`docu-notion` supports this by letting you link to database pages from your outline.
7979

8080
![image](https://user-images.githubusercontent.com/8448/168929668-f83d7c86-75d2-48e9-940c-84c5268a2854.png)
8181

8282
## Known Limitations
8383

84-
notion-pull-mdx 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-mdx will not realize this and will delete the previously published markdown file.
84+
docu-notion 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, docu-notion will not realize this and will delete the previously published markdown file.
8585

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

88-
notion-pull-mdx makes some attempt to keep the right order of things, but there are definitely cases where it isn't smart enough yet.
88+
docu-notion makes some attempt to keep the right order of things, but there are definitely cases where it isn't smart enough yet.
8989

9090
# Text Localization
9191

9292
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](https://docusaurus.io/docs/i18n/crowdin).
9393

9494
# Screenshot Localization
9595

96-
The only way we know of to provide localization of image in the current Docusaurus (2.0) is to place the images in the same directory as the markdown, and use relative paths for images. Most projects probably won't localize _every_ image, so we also need a way to "fall back" to the original screenshot when the localized one is missing. `notion-pull-mdx` facilitates this. If no localized version of an image is available, `notion-pull-mdx` places a copy of the original image into the correct location.
96+
The only way we know of to provide localization of image in the current Docusaurus (2.0) is to place the images in the same directory as the markdown, and use relative paths for images. Most projects probably won't localize _every_ image, so we also need a way to "fall back" to the original screenshot when the localized one is missing. `docu-notion` facilitates this. If no localized version of an image is available, `docu-notion` places a copy of the original image into the correct location.
9797

98-
So how do you provide these localized screenshot files? Crowdin can handle localizing assets, and in the future we may support that. For now, we currently support a different approach. If you place for example `fr https:\\imgur.com\1234.png` in the caption of a screenshot in Notion, `notion-pull-mdx` will fetch that image and save it in the right place to be found when in French mode. Getting URLs to screenshots is easy with screenshot utilities such as [Greenshot](https://getgreenshot.org/) that support uploading to imgur. Note that `notion-pull-mdx` stores a copy of all images in your source tree, so you wouldn't lose the images if imgur were to go away.
98+
So how do you provide these localized screenshot files? Crowdin can handle localizing assets, and in the future we may support that. For now, we currently support a different approach. If you place for example `fr https:\\imgur.com\1234.png` in the caption of a screenshot in Notion, `docu-notion` will fetch that image and save it in the right place to be found when in French mode. Getting URLs to screenshots is easy with screenshot utilities such as [Greenshot](https://getgreenshot.org/) that support uploading to imgur. Note that `docu-notion` stores a copy of all images in your source tree, so you wouldn't lose the images if imgur were to go away.
9999

100100
NOTE: that as far as I can tell, when you run `docusaurus start` docusaurus 2.0 offers the language picker but it doesn't actually work. So to test out the localized version, do `docusaurus build` followed by `docusaurus serve`.
101101

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
2-
"name": "notion-pull-mdx",
3-
"version": "0.0.0-development",
2+
"name": "docu-notion",
43
"description": "Download Notion pages as markdown and image files, preserving hierarchy and enabling workflow properties. Works with Docusaurus.",
54
"main": "./dist/index.js",
65
"bin": "dist/index.js",
@@ -15,12 +14,13 @@
1514
"notion-download": "node dist/index.js",
1615
"cmdhelp": "ts-node --compiler-options \"{\\\"module\\\": \\\"commonjs\\\"}\" src/index.ts",
1716
"// test out with my sample notion db": "",
17+
"t": "cross-var ts-node --compiler-options \"{\\\"module\\\": \\\"commonjs\\\"}\" src/index.ts -n %NOTION_PULL_INTEGRATION_TOKEN% -r %NOTION_PULL_ROOT_PAGE%",
1818
"sample": "cross-var ts-node --compiler-options \"{\\\"module\\\": \\\"commonjs\\\"}\" src/index.ts -n %NOTION_PULL_INTEGRATION_TOKEN% -r %NOTION_PULL_ROOT_PAGE% -m ./sample --locales en,es,fr,de --log-level verbose",
1919
"sample-with-paths": "cross-var ts-node --compiler-options \"{\\\"module\\\": \\\"commonjs\\\"}\" src/index.ts -n %NOTION_PULL_INTEGRATION_TOKEN% -r %NOTION_PULL_ROOT_PAGE% -m ./sample --img-output-path ./sample_img"
2020
},
2121
"repository": {
2222
"type": "git",
23-
"url": "git+https://github.com/sillsdev/notion-pull-mdx.git"
23+
"url": "git+https://github.com/sillsdev/docu-notion.git"
2424
},
2525
"license": "MIT",
2626
"author": {
@@ -37,9 +37,9 @@
3737
"markdown"
3838
],
3939
"bugs": {
40-
"url": "https://github.com/sillsdev/notion-pull-mdx/issues"
40+
"url": "https://github.com/sillsdev/docu-notion/issues"
4141
},
42-
"homepage": "https://github.com/sillsdev/notion-pull-mdx#readme",
42+
"homepage": "https://github.com/sillsdev/docu-notion#readme",
4343
"//file-type": "have to use this version before they switched to ESM, which gives a compile error related to require()",
4444
"//node-fetch@2.6.6file-type": "have to use this version before they switched to ESM, which gives a compile error related to require()",
4545
"//chalk@4": "also ESM related problem",

src/DocusaurusTweaks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function notionEmbedsToMDX(input: string): {
6969
regex: /\[.*\]\((http.*(\.(gif|GIF)))\)/gm,
7070
...gif,
7171
},
72-
// This is included in notion-pull-mdx just because we built notion-pull-mdx for our own doc site, and it needs this.
72+
// This is included in docu-notion just because we built docu-notion for our own doc site, and it needs this.
7373
// bloomPUB: {
7474
// regex: /\[.*\]\((.*bloomlibrary\.org.*.*book.*)\)/gm,
7575
// // enhance: it would be nice if we could fill in the `host` parameter for analytics

src/NotionImage.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ async function readPrimaryImage(imageSet: ImageSet) {
6868
async function saveImage(imageSet: ImageSet): Promise<void> {
6969
writeImageIfNew(imageSet.primaryFileOutputPath!, imageSet.primaryBuffer!);
7070

71-
let foundLocalizedImage = false;
72-
7371
for (const localizedImage of imageSet.localizedUrls) {
7472
let buffer = imageSet.primaryBuffer!;
7573
// if we have a urls for the localized screenshot, download it
@@ -87,9 +85,7 @@ async function saveImage(imageSet: ImageSet): Promise<void> {
8785
const directory = `./i18n/${
8886
localizedImage.iso632Code
8987
}/docusaurus-plugin-content-docs/current/${imageSet.relativePathToParentDocument!}`;
90-
if (!foundLocalizedImage) {
91-
foundLocalizedImage = true;
92-
}
88+
9389
writeImageIfNew(directory + "/" + imageSet.outputFileName!, buffer);
9490
}
9591
}

src/NotionPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const notionLimiter = new RateLimiter({
1616
let notionClient: Client;
1717

1818
// Notion has 2 kinds of pages: a normal one which is just content, and what I'm calling a "database page", which has whatever properties you put on it.
19-
// notion-pull-mdx supports the later via links from outline pages. That is, you put the database pages in a database, then separately, in the outline, you
19+
// docu-notion supports the later via links from outline pages. That is, you put the database pages in a database, then separately, in the outline, you
2020
// create pages for each node of the outline and then add links from those to the database pages. In this way, we get the benefits of database
2121
// pages (metadata, workflow, etc) and also normal pages (order, position in the outline).
2222
export enum PageType {

src/css/notion-styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.notion-row {
2424
display: grid;
2525
grid-auto-flow: column;
26-
/* at the moment, notion-pull-mdx doesn't give us column widths or ratios. So we
26+
/* at the moment, docu-notion doesn't give us column widths or ratios. So we
2727
could let css layout decide the widths. Instead at the moment we're saying
2828
let's just have each column be equal. This is easier for the author using
2929
Notion to remember than having to guess at what the layout will be. */

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { setLogLevel } from "./log";
66
import { notionPull, Options } from "./pull";
77
const pkg = require("../package.json");
88
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
9-
console.log(`notion-pull-mdx version ${pkg.version}`);
9+
console.log(`docu-notion version ${pkg.version}`);
1010

11-
program.name("notion-pull-mdx").description("");
11+
program.name("docu-notion").description("");
1212
program
1313
.requiredOption("-n, --notion-token <string>", "notion api token")
1414
.requiredOption(
@@ -57,7 +57,7 @@ setLogLevel(program.opts().logLevel);
5757

5858
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
5959
void notionPull(program.opts() as Options).then(() =>
60-
console.log("notion-pull-mdx Finished.")
60+
console.log("docu-notion Finished.")
6161
);
6262

6363
function parseLocales(value: string): string[] {

src/pull.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const pages = new Array<NotionPage>();
3838
export async function notionPull(incomingOptions: Options): Promise<void> {
3939
options = incomingOptions;
4040

41-
// It's helpful when troubleshooting CI secrets and environment variables to see what options actually made it to notion-pull-mdx.
41+
// It's helpful when troubleshooting CI secrets and environment variables to see what options actually made it to docu-notion.
4242
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
4343
const optionsForLogging = { ...incomingOptions };
4444
// Just show the first few letters of the notion token, which start with "secret" anyhow.
@@ -110,7 +110,7 @@ async function getPagesRecursively(
110110

111111
if (!rootLevel && pageInfo.hasParagraphs && pageInfo.childPages.length) {
112112
error(
113-
`Skipping "${pageInTheOutline.nameOrTitle}" and its children. notion-pull-mdx does not support pages that are both levels and have content at the same time.`
113+
`Skipping "${pageInTheOutline.nameOrTitle}" and its children. docu-notion does not support pages that are both levels and have content at the same time.`
114114
);
115115

116116
return;

0 commit comments

Comments
 (0)