From 980138ab3b6261b1109875d25ba452036708624c Mon Sep 17 00:00:00 2001 From: kmlbgn Date: Mon, 1 Apr 2024 14:32:10 +0800 Subject: [PATCH] fix: paths to lowercase --- .gitignore | 4 +++- src/LayoutStrategy.ts | 13 ------------- src/plugins/TableTransformer.ts | 7 ++++--- src/pull.ts | 4 ++-- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index f0b4aec..f7a6777 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,7 @@ sample_img/ i18n/ node_modules/ version.json -docs/ +tabs/ +css/ +static/ *.orig diff --git a/src/LayoutStrategy.ts b/src/LayoutStrategy.ts index cf1c151..a7ae100 100644 --- a/src/LayoutStrategy.ts +++ b/src/LayoutStrategy.ts @@ -26,17 +26,4 @@ export abstract class LayoutStrategy { // the url we return starts with a "/", meaning it is relative to the root of the markdown root (e.g. /docs root in Docusaurus) return ("/" + page.slug).replaceAll("//", "/"); } - - protected getListOfExistingFiles(dir: string): string[] { - return fs.readdirSync(dir).flatMap(item => { - const path = `${dir}/${item}`; - if (fs.statSync(path).isDirectory()) { - return this.getListOfExistingFiles(path); - } - if (path.endsWith(".mdx")) { - // we could just notice all files, and maybe that's better. But then we lose an debugging files like .json of the raw notion, on the second run. - return [path]; - } else return []; - }); - } } diff --git a/src/plugins/TableTransformer.ts b/src/plugins/TableTransformer.ts index 3422f73..bf8b94b 100644 --- a/src/plugins/TableTransformer.ts +++ b/src/plugins/TableTransformer.ts @@ -1,7 +1,8 @@ import { NotionToMarkdown } from "notion-to-md"; +import { table } from "notion-to-md/build/utils/md"; import { ListBlockChildrenResponseResult } from "notion-to-md/build/types"; import markdownTable from "markdown-table"; -import { IGetBlockChildrenFn, IDocuNotionContext, IPlugin } from "./pluginTypes"; +import { IGetBlockChildrenFn, IPlugin } from "./pluginTypes"; import { NotionBlock } from "../types"; // This is mostly a copy of the table handler from notion-to-md. The change is to handle newlines in the @@ -15,7 +16,6 @@ export async function tableTransformer( const tableArr: string[][] = []; if (has_children) { const tableRows = await getBlockChildren(id); - // console.log(">>", tableRows); const rowsPromise = tableRows?.map(async row => { const { type } = row as any; const cells = (row as any)[type]["cells"]; @@ -53,7 +53,8 @@ export async function tableTransformer( }); await Promise.all(rowsPromise || []); } - return markdownTable(tableArr); + return table(tableArr); + // return markdownTable(tableArr); } export const standardTableTransformer: IPlugin = { diff --git a/src/pull.ts b/src/pull.ts index 669c27a..f0866d1 100644 --- a/src/pull.ts +++ b/src/pull.ts @@ -89,7 +89,7 @@ export async function notionPull(options: DocuNotionOptions): Promise { } // Create a base folder using markdownOutputPath (default "tabs") - await fs.mkdir(options.markdownOutputPath.replace(/\/+$/, ""), { recursive: true }); + await fs.mkdir(options.markdownOutputPath.replace(/\/+$/, "").toLowerCase(), { recursive: true }); //TODO group stage 1 should be extracted from getTabs to here await getTabs(options, "", "root", options.rootPage); @@ -303,7 +303,7 @@ async function getTabsPagesRecursively( function writePage(page: NotionPage, finalMarkdown: string) { const mdPath = layoutStrategy.getPathForPage(page, ".mdx"); verbose(`writing ${mdPath}`); - fs.writeFileSync(mdPath, finalMarkdown, {}); + fs.writeFileSync(mdPath.toLowerCase(), finalMarkdown, {}); ++counts.output_normally; }