fabien0102 / gatsby-starter

Gatsby 2.0 starter with typescript and many cools dev tools
386 stars 99 forks source link

feature: define blog slug in frontmatter #48

Open jkornblum opened 6 years ago

jkornblum commented 6 years ago

Modify gatsby-node.js so that it reads in frontmatter slug and uses it for blog URL. If frontmatter is not defined or slug is not defined it will default to file path for slug (current behavior).

E.g. on the demo the first blog post is demo.com/blog/2017-04-18--welcoming/ by adding slug to front matter like

---
title: 'Article #2'
tags:
  - test
slug: 2017-04-18/my-article
---

the new url would be demo.com/blog/2017-04-18/my-article

fabien0102 commented 6 years ago

@jkornblum carefull you miss a semi-column ^^

gatsby-node.js:39:97
  ✖  39:97  Missing semicolon.

You can run npm run lint:js to be sure (normally it's automaticly done in a git hook with husky) 😉

jkornblum commented 6 years ago

Thanks for feedback. I tried the one liner without the checks! I was burned 😄

Anyways I updated and cleaned up code, added unit test, and changed one markdown file use the frontmatter slug.

Let me know if it looks okay.

fabien0102 commented 6 years ago

It looks good, I just need to check why netlify don't want to deploy ^^

8:29:44 AM: error Generating JavaScript bundles failed
8:29:44 AM: 
8:29:44 AM:   Error: /opt/build/repo/node_modules/@types/react/index.d.ts
8:29:44 AM:   (3508,58): error TS2304: Cannot find name 'HTMLDialogElement'.
8:29:44 AM: 

Strange… I look this after, really thank you for your PR 👍