chore(fs.dev): Extract authors from strapi
This commit is contained in:
parent
ea9b6f978a
commit
381ae9ae92
5 changed files with 177 additions and 1051 deletions
|
@ -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}"`
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue