Skip to content

Instantly share code, notes, and snippets.

@phxtho
Last active July 2, 2020 19:24
Show Gist options
  • Save phxtho/143ba0ba42fcd21429014d01da7ce512 to your computer and use it in GitHub Desktop.
Save phxtho/143ba0ba42fcd21429014d01da7ce512 to your computer and use it in GitHub Desktop.
/*
* Added the following to https://github.com/houshuang/roam-export/blob/master/index.mjs
*/
if (action === "--foam") {
let dir = 'export'
// Create the output dir if it doesn't exist
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
pagesRaw.forEach((page) => {
// Output with page title for[[wiki-links]] graph view
let output = `# ${page.title} \n${processText(pages[page.title])}\n`
// Add backlinks if the page has them
if (linkedReferences[page.title])
{
output += `
## Backlinks
${renderLinkedReferences(linkedReferences[page.title])}`
}
fs.writeFileSync(`${dir}/${page.title}.md`, output);
})
console.log(`Exported ${pagesRaw.length} pages`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment