Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
fix(docz-core): prevent entries block when parse mdx crash
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Sep 11, 2018
1 parent 18c744d commit 07ae769
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions packages/docz-core/src/Entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,29 @@ export class Entries {
})

const createEntry = async (file: string) => {
const ast = await parseMdx(file)
const entry = new Entry(ast, file, src)

if (this.repoEditUrl) entry.setLink(this.repoEditUrl)
const { settings, ...rest } = entry

return {
...settings,
...rest,
try {
const ast = await parseMdx(file)
const entry = new Entry(ast, file, src)

if (this.repoEditUrl) entry.setLink(this.repoEditUrl)
const { settings, ...rest } = entry

return {
...settings,
...rest,
}
} catch (err) {
return null
}
}

const map = new Map()
const entries = await Promise.all(files.map(createEntry))
const entries = await Promise.all(files.map(createEntry).filter(Boolean))

for (const entry of entries) {
map.set(entry.filepath, entry)
if (entry) {
map.set(entry.filepath, entry)
}
}

this.all = map
Expand Down

0 comments on commit 07ae769

Please sign in to comment.