Add 'Core' section.
This commit is contained in:
@@ -4,17 +4,18 @@ const languages = ['terrace', 'json', 'yaml', 'toml', 'javascript', 'typescript'
|
||||
|
||||
module.exports = async (doc, rootLevel) => {
|
||||
const { next, level, line, head, tail } = doc
|
||||
const codeExample = {
|
||||
type: 'CodeExample',
|
||||
|
||||
const node = {
|
||||
type: head(),
|
||||
languages: {}
|
||||
}
|
||||
|
||||
while (await next(rootLevel)) {
|
||||
const languageLevel = level()
|
||||
if (languages.includes(head())) {
|
||||
codeExample.languages[head()] = await contentAsText(doc, languageLevel)
|
||||
node.languages[head()] = await contentAsText(doc, languageLevel)
|
||||
}
|
||||
}
|
||||
|
||||
return codeExample
|
||||
return node
|
||||
}
|
||||
|
||||
16
docs/parser/nodes/Header.js
Normal file
16
docs/parser/nodes/Header.js
Normal file
@@ -0,0 +1,16 @@
|
||||
module.exports = async function (doc, rootLevel) {
|
||||
const { next, line, match, tail, level, head } = doc
|
||||
|
||||
const node = {
|
||||
type: head(),
|
||||
level: tail().split(' ')[0],
|
||||
text: tail().split(' ').slice(1).join(' '),
|
||||
class: ''
|
||||
}
|
||||
|
||||
while (await next(rootLevel)) {
|
||||
if (match('class')) node.class = tail()
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
10
docs/parser/nodes/Icon.js
Normal file
10
docs/parser/nodes/Icon.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = async function (doc) {
|
||||
const { head, tail } = doc
|
||||
|
||||
const node = {
|
||||
type: head(),
|
||||
icon: tail()
|
||||
}
|
||||
|
||||
return node
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
const { contentAsText } = require('../helpers.js')
|
||||
const marked = require('marked')
|
||||
|
||||
module.exports = async (...args) => {
|
||||
module.exports = async (doc, rootLevel) => {
|
||||
return {
|
||||
type: `Markdown`,
|
||||
text: marked.parse(await contentAsText(...args))
|
||||
type: doc.head(),
|
||||
text: marked.parse(await contentAsText(doc, rootLevel))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
const parseNode = require('./Node.js')
|
||||
|
||||
module.exports.Div = parseNode
|
||||
module.exports.Section = async (doc, rootLevel) => {
|
||||
const variant = doc.tail()
|
||||
return { variant, ...(await parseNode(doc, rootLevel)) }
|
||||
}
|
||||
module.exports.Header = require('./Header.js')
|
||||
module.exports.Button = require('./Button.js')
|
||||
module.exports.Icon = require('./Icon.js')
|
||||
|
||||
module.exports.Div = parseNode
|
||||
module.exports.Markdown = require('./Markdown.js')
|
||||
module.exports.CodeExample = require('./CodeExample.js')
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user