First pass at hero section.

This commit is contained in:
Joshua Bemenderfer
2023-02-12 20:49:04 -05:00
parent 95842b73bd
commit df3aa36e26
14 changed files with 112 additions and 18 deletions

View File

@@ -0,0 +1,23 @@
const { contentAsText } = require('../helpers.js')
module.exports = async function (doc, rootLevel) {
const { next, line, match, tail, level, head } = doc
const node = {
type: head(),
variant: tail() || 'neutral',
class: '',
href: '',
text: ''
}
while (await next(rootLevel)) {
if (match('class')) node.class = tail()
else if (match('href')) node.href = tail()
else {
node.text = await contentAsText(doc, rootLevel, true)
}
}
return node
}

View File

@@ -1,7 +1,15 @@
const parseNode = require('./Node.js')
module.exports.Section = parseNode
module.exports.Section = async (doc, rootLevel) => {
const variant = doc.tail()
return { variant, ...(await parseNode(doc, rootLevel)) }
}
module.exports.Div = parseNode
module.exports.Logo = doc => ({ type: `Logo` })
module.exports.Logo = doc => ({
type: `Logo`,
variant: doc.tail() || 'light'
})
module.exports.Markdown = require('./Markdown.js')
module.exports.CodeExample = require('./CodeExample.js')
module.exports.Button = require('./Button.js')