- Install github.com/andreoliwa/logseq-doctor
- Load markdown files into a folder
- Then run:
mkdir node mkdir lsd node index cd node for f in ./*.md; do echo $f & lsd outline $f > ../lsd/$f; done
Created
October 11, 2022 00:16
-
-
Save janbaykara/4d24163cca034e233b5ef1213d11560b to your computer and use it in GitHub Desktop.
Script to prepare Notion markdown pages for Logseq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs") | |
const glob = require('glob') | |
const slugify = require('slugify') | |
// load all .md files via glob | |
const paths = glob.sync("./*.md") | |
for (const path of paths) { | |
let props = { | |
"origin": "Notion" | |
} | |
let file = fs.readFileSync(path, "utf-8") | |
const title = /^(?<!\n)# (.*)/.exec(file)[1] | |
file = file.split(title + "\n\n")[1] | |
let [frontmatter, ...content] = file.split(/\n\n/) | |
content = content.join("\n\n") | |
for (const line of frontmatter.split("\n")) { | |
const [key, colon, ...value] = line.split(":") | |
props[slugify(key.trim())] = value.join(":").trim() | |
} | |
const frontmatterString = Object.entries(props).map(([k, v]) => `- ${k}:: ${v}`).join("\n") | |
// content = content.replace(/\[ \]/, "LATER") | |
// content = content.replace(/\[[xX]{1}]/, "DONE") | |
content = content.replace(/^[\s]*-{2,}[\s]*$/mig, "-") | |
content = content.replace(/^[\s]*\*{2,}[\s]*$/mig, "-") | |
content = content.replace(/^[\s]*\* \* \*[\s]*$/mig, "-") | |
file = `${frontmatterString}\n\n${content}` | |
fs.writeFileSync(`./node/${encodeURIComponent(title).replaceAll("%20", " ")}.md`, file, 'utf-8') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment