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

Interested in more daily treasures like this one?
Sent directly to your inbox?