1
0
Fork 0

chore(fs.dev): Extract authors from strapi

This commit is contained in:
Joost De Cock 2021-12-12 12:25:44 +01:00
parent ea9b6f978a
commit 381ae9ae92
5 changed files with 177 additions and 1051 deletions

View file

@ -27,7 +27,7 @@ const asText = [
// The actual plugin starts here
export const remarkIntroPlugin = () => {
// Only do something if there is frontmatter
// Check to see whether the node has frontmatter
const hasFrontmatter = node => (node.children[0].type === 'yaml')
// Pulls text out of a paragraph
@ -52,9 +52,14 @@ export const remarkIntroPlugin = () => {
// Tree visitor
const visitor = (node) => {
const intro = extractFirstParagraph(node)
if (hasFrontmatter(node)) {
const intro = extractFirstParagraph(node)
node.children[0].value += `\nintro: "${intro}"`
} else {
node.children.unshift({
type: 'yaml',
value: `intro: "${intro}"`
})
}
}