Ola adds a slug field to his homemade markdown node
My Sunday Skill Builder Session:
This Sunday, I added a slug field to my homemade markdown node π
What did I do?
I added a slug field to my homemade markdown node with createNodeField from the onCreateNode hook.
Why did I do it?
I need that slug to add support for a basic content section to create Markdown marketing pages with sections for Queen @raae's usepow.app.
How did I do it?
Short version:
// POW!-website / gatsby - node.js;
async function slugifyMarkdownRemarkNode({ actions, node, getNode }) {
const { createNodeField } = actions;
if (node.internal.type === "MarkdownRemark") {
const slug = createFilePath({ node, getNode });
createNodeField({
name: "slug",
node,
value: slug,
});
}
}
exports.onCreateNode = async (gatsbyUtils) => {
await Promise.all([slugifyMarkdownRemarkNode(gatsbyUtils)]);
};
Cheat Sheet:
// POW!-site/gatsby-node.js
async function slugifyMarkdownRemarkNode({ actions, node, getNode }) {
// π¨π°π
con
// my md type of node ... internal
if ( ) {
// π = π¨ + π + π’ ({ node, getNode })
con
// π¨π°π ({ π, π°, π })
cre
na
no
va
})
}
};
If you can guess what one of the emojis mean, reply to this email πΊπ
Long version: Sunday's OlaCast on YouTube
Β
πͺπΊπ
Keep your skill-builder-ship afloat this week!
β΅π§π΄ββ οΈ
Ola Vea
Cap'n of his own skill-builder-ship