Start working on docs site.
This commit is contained in:
31
docs/parser/page.js
Normal file
31
docs/parser/page.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const parseSection = require('./section.js')
|
||||
|
||||
module.exports = async function(doc) {
|
||||
const { next, line, match, tail, level, head } = doc
|
||||
|
||||
const pageData = {
|
||||
title: '',
|
||||
description: [],
|
||||
layout: '',
|
||||
sections: []
|
||||
}
|
||||
|
||||
while(await next()) {
|
||||
if (!line()) continue
|
||||
if (match('title')) pageData.title = tail()
|
||||
else if (match('layout')) pageData.layout = tail()
|
||||
else if (match('description')) {
|
||||
const l = level()
|
||||
while(await next(l)) {
|
||||
pageData.description.push(line(l))
|
||||
}
|
||||
}
|
||||
else if (match('section')) {
|
||||
pageData.sections.push(await parseSection(doc, level()))
|
||||
}
|
||||
}
|
||||
|
||||
console.dir(pageData, { depth: null })
|
||||
|
||||
return pageData
|
||||
}
|
||||
27
docs/parser/section.js
Normal file
27
docs/parser/section.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const parseSection = require('./section.js')
|
||||
|
||||
const knownBlocks = {
|
||||
'logo': () => {},
|
||||
'div': () => {},
|
||||
'markdown': () => {},
|
||||
}
|
||||
|
||||
module.exports = async function(doc, rootLevel) {
|
||||
const { next, line, match, tail, level, head } = doc
|
||||
|
||||
const section = {
|
||||
class: '',
|
||||
children: []
|
||||
}
|
||||
|
||||
while (await next(rootLevel)) {
|
||||
if (!head()) continue
|
||||
const block = head()
|
||||
if (!knownBlocks[block]) continue
|
||||
|
||||
// TODO: Start Parsing
|
||||
section.children.push(line())
|
||||
}
|
||||
|
||||
return section
|
||||
}
|
||||
Reference in New Issue
Block a user