Task #27 - Fix for export markdown functions and click link markdown type
This commit is contained in:
parent
270da67977
commit
d3cd8b4d38
@ -41,29 +41,33 @@ class Export extends Controller {
|
||||
|
||||
await fs.mkdir(temp_dir)
|
||||
this._markdown_recurse(page0, temp_dir)
|
||||
return res.api({temp_dir})
|
||||
return res.api({ temp_dir })
|
||||
}
|
||||
|
||||
async _markdown_recurse(root, temp_dir) {
|
||||
async _markdown_recurse(root, temp_dir) { //recursive function for creating directory and generating markdown pages
|
||||
console.log('root', root)
|
||||
const Page = this.models.get('api:Page')
|
||||
//const child = await root.childPages
|
||||
const child = await Page.find({ UUID: { $in: root.ChildPageIds }})
|
||||
console.log('child', child)
|
||||
const child = await Page.find({ UUID: { $in: root.ChildPageIds } })
|
||||
|
||||
for (const page of child) {
|
||||
const markdown = this._generate_markdown(page)
|
||||
if (page.ChildPageIds && page.ChildPageIds.length) {
|
||||
const sub_temp_dir = path.resolve(temp_dir, page.Name.replace(/\s/g, '_'))
|
||||
console.log('page', page, 'sub_temp', sub_temp_dir)
|
||||
await fs.mkdir(sub_temp_dir)
|
||||
this._markdown_recurse(page, sub_temp_dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
async _generate_markdown(page) {
|
||||
async _generate_markdown(page) { //generate mark down
|
||||
const Node = this.models.get('api:Node')
|
||||
const nodes = await Node.find({ PageId: page.UUID })
|
||||
return nodes.map(x => { return x.Value.Value }).join('\n')
|
||||
return nodes.map(x => {
|
||||
if (x.Type === 'click_link') {
|
||||
return '[' + x.Value.Value + ']' + '(' + x.Value.Value + ')'
|
||||
}
|
||||
return x.Value.Value
|
||||
}).join('\n')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user