Skip to content

Commit c1b15bf

Browse files
committed
Changes after review
1 parent 071ad79 commit c1b15bf

27 files changed

+74
-7883
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ i18n/
55
node_modules/
66
version.json
77
docs/
8+
yarn-error.log

docu-notion.config.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import {
2-
IDocuNotionConfig,
3-
IPlugin,
4-
NotionBlock,
5-
} from "./dist/config/configuration";
6-
import { verbose } from "./dist/log";
1+
/* This file is only used when testing docu-notion itself, not when it is used as a library.
2+
E.g., if you run `yarn pull-test-tagged`, docu-notion will read this file and use it to configure itself,
3+
using these example plugins.
4+
*/
5+
6+
import { IDocuNotionConfig } from "./dist/config/configuration";
7+
import { IPlugin, Log } from "./dist";
8+
import { NotionBlock } from "./dist/types";
79

810
const dummyBlockModifier: IPlugin = {
911
name: "dummyBlockModifier",
1012

1113
notionBlockModifications: [
1214
{
1315
modify: (block: NotionBlock) => {
14-
verbose("dummyBlockModifier was called");
16+
Log.verbose("dummyBlockModifier was called");
1517
},
1618
},
1719
],

src/NotionPage.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ export class NotionPage {
2626
public layoutContext: string; // where we found it in the hierarchy of the outline
2727
public foundDirectlyInOutline: boolean; // the page was found as a descendent of /outline instead of being linked to
2828

29-
// public constructor(
30-
// layoutContext: string,
31-
// pageId: string,
32-
// order: number,
33-
// metadata: GetPageResponse,
34-
// foundDirectlyInOutline: boolean
35-
// ) {
36-
// this.layoutContext = layoutContext;
37-
// this.pageId = pageId;
38-
// this.order = order;
39-
// this.metadata = metadata;
40-
// this.foundDirectlyInOutline = foundDirectlyInOutline;
41-
42-
// // review: this is expensive to learn as it takes another api call... I
43-
// // think? We can tell if it's a database because it has a "Name" instead of a
44-
// // "tile" and "parent": "type": "database_id". But do we need to differentiate
45-
// //this.type = PageType.Unknown;
46-
// }
4729
public constructor(args: {
4830
layoutContext: string;
4931
pageId: string;

src/config/configuration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import * as Cosmic from "cosmiconfig";
22
import defaultConfig from "./default.docunotion.config";
33
import { error, verbose } from "../log";
44
import { TypeScriptLoader } from "cosmiconfig-typescript-loader";
5-
import { IDocuNotionConfig, IPlugin } from "../plugins/pluginTypes";
5+
import { IPlugin } from "../plugins/pluginTypes";
6+
7+
export type IDocuNotionConfig = {
8+
plugins: IPlugin[];
9+
};
610

711
// read the plugins from the config file
812
// and add them to the map

src/config/default.docunotion.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { standardEscapeHtmlBlockModifier } from "../plugins/EscapeHtmlBlockModif
1313
import { standardHeadingTransformer } from "../plugins/HeadingTransformer";
1414
import { standardNumberedListTransformer } from "../plugins/NumberedListTransformer";
1515
import { standardTableTransformer } from "../plugins/TableTransformer";
16-
import { IDocuNotionConfig } from "../plugins/pluginTypes";
1716
import { standardExternalLinkConversion } from "../plugins/externalLinks";
17+
import { IDocuNotionConfig } from "./configuration";
1818

1919
const defaultConfig: IDocuNotionConfig = {
2020
plugins: [

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ run();
77
// for plugins to import
88

99
export * as Log from "./log";
10+
export * from "./types";
1011
export * from "./plugins/pluginTypes";

src/plugins/CalloutTransformer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { NotionBlock } from "./pluginTypes";
1+
import { NotionBlock } from "../types";
22
import { NotionPage } from "../NotionPage";
3-
import { blocksToMarkdown, makeSamplePageObject } from "../TestRun";
3+
import { blocksToMarkdown, makeSamplePageObject } from "./pluginTestRun";
44
import { standardCalloutTransformer } from "./CalloutTransformer";
55
import { standardExternalLinkConversion } from "./externalLinks";
66
import { standardInternalLinkConversion } from "./internalLinks";

src/plugins/CalloutTransformer.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { NotionToMarkdown } from "notion-to-md";
2-
import {
3-
ListBlockChildrenResponseResult,
4-
ListBlockChildrenResponseResults,
5-
} from "notion-to-md/build/types";
6-
// import { Client } from "@notionhq/client";
7-
// import { getBlockChildren } from "./CustomTransformers";
8-
import { IPlugin, NotionBlock } from "./pluginTypes";
2+
import { NotionBlock } from "../types";
3+
import { IPlugin } from "./pluginTypes";
94

105
// In Notion, you can make a callout and change its emoji. We map 5 of these
116
// to the 5 Docusaurus admonition styles.
@@ -14,7 +9,7 @@ import { IPlugin, NotionBlock } from "./pluginTypes";
149
// Note: I haven't yet tested this with any emoji except "💡"/"tip", nor the case where the
1510
// callout has-children. Not even sure what that would mean, since the document I was testing
1611
// with has quite complex markup inside the callout, but still takes the no-children branch.
17-
export async function notionCalloutToAdmonition(
12+
async function notionCalloutToAdmonition(
1813
notionToMarkdown: NotionToMarkdown,
1914
getBlockChildren: (id: string) => Promise<NotionBlock[]>,
2015
block: NotionBlock

src/plugins/ColumnListTransformer.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { NotionToMarkdown } from "notion-to-md";
2-
import { IPlugin, NotionBlock } from "./pluginTypes";
2+
import { NotionBlock } from "../types";
3+
import { IPlugin } from "./pluginTypes";
34

4-
export async function notionColumnListToMarkdown(
5+
async function notionColumnListToMarkdown(
56
notionToMarkdown: NotionToMarkdown,
67
getBlockChildren: (id: string) => Promise<NotionBlock[]>,
78
block: NotionBlock

src/plugins/ColumnTransformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const standardColumnTransformer: IPlugin = {
1919
};
2020

2121
// This runs when notion-to-md encounters a column block
22-
export async function notionColumnToMarkdown(
22+
async function notionColumnToMarkdown(
2323
notionToMarkdown: NotionToMarkdown,
2424
getBlockChildren: IGetBlockChildrenFn,
2525
block: ListBlockChildrenResponseResult

0 commit comments

Comments
 (0)