Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} from "graphql"
import {
connectionFromArray,
connectionArgs,
connectionDefinitions,
} from "graphql-relay"
import inferGraphQLType from "./infer-graphql-type"
import { nodeInterface } from "./node"
import createPath from "../bootstrap/create-path"
// Setup Markdown parsing.
const remark = remarkAbstract({ commonmark: true })
const thing = {}
remarkHtmlAbstract(thing)
module.exports = directory =>
new Promise((resolve, reject) => {
let pages = []
glob(`${directory}/**/*.md`, (err, files) => {
if (err) return reject(err)
_.each(files, file => {
const page = {}
page.src = fs.readFileSync(file, `utf-8`)
const ast = remark.parse(page.src)
page.ast = ast
page.bodyHTML = thing.Compiler.prototype.compile(page.ast)
page.headings = select(ast, `heading`).map(heading => ({
value: _.first(select(heading, `text`).map(text => text.value)),
depth: heading.depth,
}))