Skip to content

Commit

Permalink
Merge pull request #35 from kmlbgn/master
Browse files Browse the repository at this point in the history
fix: paths to lowercase
  • Loading branch information
kmlbgn authored Apr 1, 2024
2 parents 6fa29ee + 980138a commit 522ad92
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ sample_img/
i18n/
node_modules/
version.json
docs/
tabs/
css/
static/
*.orig
13 changes: 0 additions & 13 deletions src/LayoutStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
});
}
}
7 changes: 4 additions & 3 deletions src/plugins/TableTransformer.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"];
Expand Down Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function notionPull(options: DocuNotionOptions): Promise<void> {
}

// 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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 522ad92

Please sign in to comment.