Use auto-generated slugs + various other fixes

This commit is contained in:
Kyle Mathews 2017-11-12 18:17:46 -08:00
parent 18c89a9431
commit 6d51a2cc86
11 changed files with 170 additions and 177 deletions

View file

@ -1,4 +1,4 @@
const _ = require("lodash") const _ = require('lodash')
const Promise = require('bluebird') const Promise = require('bluebird')
const path = require('path') const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem') const { createFilePath } = require('gatsby-source-filesystem')
@ -7,7 +7,7 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
const { createPage } = boundActionCreators const { createPage } = boundActionCreators
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const blogPost = path.resolve("./src/templates/blog-post.js") const blogPost = path.resolve('./src/templates/blog-post.js')
resolve( resolve(
graphql( graphql(
` `
@ -15,8 +15,8 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
allMarkdownRemark(limit: 1000) { allMarkdownRemark(limit: 1000) {
edges { edges {
node { node {
frontmatter { fields {
path slug
} }
} }
} }
@ -32,10 +32,10 @@ exports.createPages = ({ graphql, boundActionCreators }) => {
// Create blog posts pages. // Create blog posts pages.
_.each(result.data.allMarkdownRemark.edges, edge => { _.each(result.data.allMarkdownRemark.edges, edge => {
createPage({ createPage({
path: edge.node.frontmatter.path, path: edge.node.fields.slug,
component: blogPost, component: blogPost,
context: { context: {
path: edge.node.frontmatter.path, slug: edge.node.fields.slug,
}, },
}) })
}) })

View file

@ -48,7 +48,7 @@
"dev": "gatsby develop", "dev": "gatsby develop",
"lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .", "lint": "./node_modules/.bin/eslint --ext .js,.jsx --ignore-pattern public .",
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js'", "format": "prettier --trailing-comma es5 --no-semi --single-quote --write 'src/**/*.js' 'src/**/*.md'",
"develop": "gatsby develop", "develop": "gatsby develop",
"build": "gatsby build", "build": "gatsby build",
"deploy": "gatsby build --prefix-paths && gh-pages -d public", "deploy": "gatsby build --prefix-paths && gh-pages -d public",

View file

@ -1,15 +0,0 @@
---
title: Hello World
date: "2015-05-01T22:12:03.284Z"
path: "/hello-world/"
---
This is my first post on my new fake blog! How exciting!
I'm sure I'll write a lot more interesting things in the future.
Oh, and here's a great quote from this Wikipedia on [salted duck eggs](http://en.wikipedia.org/wiki/Salted_duck_egg).
>A salted duck egg is a Chinese preserved food product made by soaking duck eggs in brine, or packing each egg in damp, salted charcoal. In Asian supermarkets, these eggs are sometimes sold covered in a thick layer of salted charcoal paste. The eggs may also be sold with the salted paste removed, wrapped in plastic, and vacuum packed. From the salt curing process, the salted duck eggs have a briny aroma, a gelatin-like egg white and a firm-textured, round yolk that is bright orange-red in color.
![Chinese Salty Egg](./salty_egg.jpg)

View file

@ -1,11 +0,0 @@
---
title: My Second Post!
date: "2015-05-06T23:46:37.121Z"
path: "/my-second-post/"
---
Wow! I love blogging so much already.
Did you know that "despite its name, salted duck eggs can also be made from chicken eggs, though the taste and texture will be somewhat different, and the egg yolk will be less rich."? ([Wikipedia Link](http://en.wikipedia.org/wiki/Salted_duck_egg))
Yeah, I didn't either.

View file

@ -1,117 +0,0 @@
---
title: New Beginnings
date: "2015-05-28T22:40:32.169Z"
path: "/hi-folks/"
---
Far far away, behind the word mountains, far from the countries Vokalia
and Consonantia, there live the blind texts. Separated they live in
Bookmarksgrove right at the coast of the Semantics, a large language
ocean. A small river named Duden flows by their place and supplies it
with the necessary regelialia.
## On deer horse aboard tritely yikes and much
The Big Oxmox advised her not to do so, because there were thousands of
bad Commas, wild Question Marks and devious Semikoli, but the Little
Blind Text didnt listen. She packed her seven versalia, put her initial
into the belt and made herself on the way.
* This however showed weasel
* Well uncritical so misled
* this is very interesting
* Goodness much until that fluid owl
When she reached the first hills of the **Italic Mountains**, she
had a last view back on the skyline of her
hometown _Bookmarksgrove_, the headline of [Alphabet
Village](http://google.com) and the subline of her own road, the
Line Lane. Pityful a rethoric question ran over her cheek, then she
continued her way. On her way she met a copy.
### Overlaid the jeepers uselessly much excluding
But nothing the copy said could convince her and so it didnt take
long until a few insidious Copy Writers ambushed her, made her drunk
with [Longe and Parole](http://google.com) and dragged her into
their agency, where they abused her for their projects again and
again. And if she hasnt been rewritten, then they are still using
her.
> Far far away, behind the word mountains, far from the countries
> Vokalia and Consonantia, there live the blind texts. Separated
> they live in Bookmarksgrove right at the coast of the Semantics, a
> large language ocean. 
It is a paradisematic country, in which roasted parts of sentences
fly into your mouth. Even the all-powerful Pointing has no control
about the blind texts it is an almost unorthographic life One day
however a small line of blind text by the name of Lorem Ipsum
decided to leave for the far World of Grammar.
### According a funnily until pre-set or arrogant well cheerful
The Big Oxmox advised her not to do so, because there were thousands
of bad Commas, wild Question Marks and devious Semikoli, but the
Little Blind Text didnt listen. She packed her seven versalia, put
her initial into the belt and made herself on the way.
1. So baboon this
2. Mounted militant weasel gregariously admonishingly straightly hey
3. Dear foresaw hungry and much some overhung
4. Rash opossum less because less some amid besides yikes jeepers frenetic impassive fruitlessly shut
When she reached the first hills of the Italic Mountains, she had a
last view back on the skyline of her hometown Bookmarksgrove, the
headline of Alphabet Village and the subline of her own road, the
Line Lane. Pityful a rethoric question ran over her cheek, then she
continued her way. On her way she met a copy.
> The copy warned the Little Blind Text, that where it came from it
> would have been rewritten a thousand times and everything that was
> left from its origin would be the word "and" and the Little Blind
> Text should turn around and return to its own, safe country.
But nothing the copy said could convince her and so it didnt take
long until a few insidious Copy Writers ambushed her, made her drunk
with Longe and Parole and dragged her into their agency, where they
abused her for their projects again and again. And if she hasnt
been rewritten, then they are still using her. Far far away, behind
the word mountains, far from the countries Vokalia and Consonantia,
there live the blind texts.
#### Silent delightfully including because before one up barring chameleon
Separated they live in Bookmarksgrove right at the coast of the
Semantics, a large language ocean. A small river named Duden flows
by their place and supplies it with the necessary regelialia. It is
a paradisematic country, in which roasted parts of sentences fly
into your mouth.
Even the all-powerful Pointing has no control about the blind texts
it is an almost unorthographic life One day however a small line of
blind text by the name of Lorem Ipsum decided to leave for the far
World of Grammar. The Big Oxmox advised her not to do so, because
there were thousands of bad Commas, wild Question Marks and devious
Semikoli, but the Little Blind Text didnt listen.
##### Wherever far wow thus a squirrel raccoon jeez jaguar this from along
She packed her seven versalia, put her initial into the belt and
made herself on the way. When she reached the first hills of the
Italic Mountains, she had a last view back on the skyline of her
hometown Bookmarksgrove, the headline of Alphabet Village and the
subline of her own road, the Line Lane. Pityful a rethoric question
ran over her cheek, then she continued her way. On her way she met a
copy.
###### Slapped cozy a that lightheartedly and far
The copy warned the Little Blind Text, that where it came from it
would have been rewritten a thousand times and everything that was
left from its origin would be the word "and" and the Little Blind
Text should turn around and return to its own, safe country. But
nothing the copy said could convince her and so it didnt take long
until a few insidious Copy Writers ambushed her, made her drunk with
Longe and Parole and dragged her into their agency, where they
abused her for their projects again and again.

View file

@ -0,0 +1,21 @@
---
title: Hello World
date: "2015-05-01T22:12:03.284Z"
---
This is my first post on my new fake blog! How exciting!
I'm sure I'll write a lot more interesting things in the future.
Oh, and here's a great quote from this Wikipedia on
[salted duck eggs](http://en.wikipedia.org/wiki/Salted_duck_egg).
> A salted duck egg is a Chinese preserved food product made by soaking duck
> eggs in brine, or packing each egg in damp, salted charcoal. In Asian
> supermarkets, these eggs are sometimes sold covered in a thick layer of salted
> charcoal paste. The eggs may also be sold with the salted paste removed,
> wrapped in plastic, and vacuum packed. From the salt curing process, the
> salted duck eggs have a briny aroma, a gelatin-like egg white and a
> firm-textured, round yolk that is bright orange-red in color.
![Chinese Salty Egg](./salty_egg.jpg)

View file

Before

Width:  |  Height:  |  Size: 668 KiB

After

Width:  |  Height:  |  Size: 668 KiB

Before After
Before After

107
src/pages/hi-folks/index.md Normal file
View file

@ -0,0 +1,107 @@
---
title: New Beginnings
date: "2015-05-28T22:40:32.169Z"
---
Far far away, behind the word mountains, far from the countries Vokalia and
Consonantia, there live the blind texts. Separated they live in Bookmarksgrove
right at the coast of the Semantics, a large language ocean. A small river named
Duden flows by their place and supplies it with the necessary regelialia.
## On deer horse aboard tritely yikes and much
The Big Oxmox advised her not to do so, because there were thousands of bad
Commas, wild Question Marks and devious Semikoli, but the Little Blind Text
didnt listen. She packed her seven versalia, put her initial into the belt and
made herself on the way.
* This however showed weasel
* Well uncritical so misled
* this is very interesting
* Goodness much until that fluid owl
When she reached the first hills of the **Italic Mountains**, she had a last
view back on the skyline of her hometown _Bookmarksgrove_, the headline of
[Alphabet Village](http://google.com) and the subline of her own road, the Line
Lane. Pityful a rethoric question ran over her cheek, then she continued her
way. On her way she met a copy.
### Overlaid the jeepers uselessly much excluding
But nothing the copy said could convince her and so it didnt take long until a
few insidious Copy Writers ambushed her, made her drunk with
[Longe and Parole](http://google.com) and dragged her into their agency, where
they abused her for their projects again and again. And if she hasnt been
rewritten, then they are still using her.
> Far far away, behind the word mountains, far from the countries Vokalia and
> Consonantia, there live the blind texts. Separated they live in Bookmarksgrove
> right at the coast of the Semantics, a large language ocean.
It is a paradisematic country, in which roasted parts of sentences fly into your
mouth. Even the all-powerful Pointing has no control about the blind texts it is
an almost unorthographic life One day however a small line of blind text by the
name of Lorem Ipsum decided to leave for the far World of Grammar.
### According a funnily until pre-set or arrogant well cheerful
The Big Oxmox advised her not to do so, because there were thousands of bad
Commas, wild Question Marks and devious Semikoli, but the Little Blind Text
didnt listen. She packed her seven versalia, put her initial into the belt and
made herself on the way.
1. So baboon this
2. Mounted militant weasel gregariously admonishingly straightly hey
3. Dear foresaw hungry and much some overhung
4. Rash opossum less because less some amid besides yikes jeepers frenetic
impassive fruitlessly shut
When she reached the first hills of the Italic Mountains, she had a last view
back on the skyline of her hometown Bookmarksgrove, the headline of Alphabet
Village and the subline of her own road, the Line Lane. Pityful a rethoric
question ran over her cheek, then she continued her way. On her way she met a
copy.
> The copy warned the Little Blind Text, that where it came from it would have
> been rewritten a thousand times and everything that was left from its origin
> would be the word "and" and the Little Blind Text should turn around and
> return to its own, safe country.
But nothing the copy said could convince her and so it didnt take long until a
few insidious Copy Writers ambushed her, made her drunk with Longe and Parole
and dragged her into their agency, where they abused her for their projects
again and again. And if she hasnt been rewritten, then they are still using
her. Far far away, behind the word mountains, far from the countries Vokalia and
Consonantia, there live the blind texts.
#### Silent delightfully including because before one up barring chameleon
Separated they live in Bookmarksgrove right at the coast of the Semantics, a
large language ocean. A small river named Duden flows by their place and
supplies it with the necessary regelialia. It is a paradisematic country, in
which roasted parts of sentences fly into your mouth.
Even the all-powerful Pointing has no control about the blind texts it is an
almost unorthographic life One day however a small line of blind text by the
name of Lorem Ipsum decided to leave for the far World of Grammar. The Big Oxmox
advised her not to do so, because there were thousands of bad Commas, wild
Question Marks and devious Semikoli, but the Little Blind Text didnt listen.
##### Wherever far wow thus a squirrel raccoon jeez jaguar this from along
She packed her seven versalia, put her initial into the belt and made herself on
the way. When she reached the first hills of the Italic Mountains, she had a
last view back on the skyline of her hometown Bookmarksgrove, the headline of
Alphabet Village and the subline of her own road, the Line Lane. Pityful a
rethoric question ran over her cheek, then she continued her way. On her way she
met a copy.
###### Slapped cozy a that lightheartedly and far
The copy warned the Little Blind Text, that where it came from it would have
been rewritten a thousand times and everything that was left from its origin
would be the word "and" and the Little Blind Text should turn around and return
to its own, safe country. But nothing the copy said could convince her and so it
didnt take long until a few insidious Copy Writers ambushed her, made her drunk
with Longe and Parole and dragged her into their agency, where they abused her
for their projects again and again.

View file

@ -15,28 +15,23 @@ class BlogIndex extends React.Component {
<div> <div>
<Helmet title={siteTitle} /> <Helmet title={siteTitle} />
<Bio /> <Bio />
{posts.map(post => { {posts.map(({ node }) => {
if (post.node.frontmatter.path !== '/404/') { const title = get(node, 'frontmatter.title') || node.fields.slug
const title = get(post, 'node.frontmatter.title') || post.node.path
return ( return (
<div key={post.node.frontmatter.path}> <div key={node.fields.slug}>
<h3 <h3
style={{ style={{
marginBottom: rhythm(1 / 4), marginBottom: rhythm(1 / 4),
}} }}
> >
<Link <Link style={{ boxShadow: 'none' }} to={node.fields.slug}>
style={{ boxShadow: 'none' }}
to={post.node.frontmatter.path}
>
{title} {title}
</Link> </Link>
</h3> </h3>
<small>{post.node.frontmatter.date}</small> <small>{node.frontmatter.date}</small>
<p dangerouslySetInnerHTML={{ __html: post.node.excerpt }} /> <p dangerouslySetInnerHTML={{ __html: node.excerpt }} />
</div> </div>
) )
}
})} })}
</div> </div>
) )
@ -56,11 +51,11 @@ export const pageQuery = graphql`
edges { edges {
node { node {
excerpt excerpt
frontmatter { fields {
path slug
date(formatString: "DD MMMM, YYYY")
} }
frontmatter { frontmatter {
date(formatString: "DD MMMM, YYYY")
title title
} }
} }

View file

@ -0,0 +1,13 @@
---
title: My Second Post!
date: "2015-05-06T23:46:37.121Z"
---
Wow! I love blogging so much already.
Did you know that "despite its name, salted duck eggs can also be made from
chicken eggs, though the taste and texture will be somewhat different, and the
egg yolk will be less rich."?
([Wikipedia Link](http://en.wikipedia.org/wiki/Salted_duck_egg))
Yeah, I didn't either.

View file

@ -39,14 +39,14 @@ class BlogPostTemplate extends React.Component {
export default BlogPostTemplate export default BlogPostTemplate
export const pageQuery = graphql` export const pageQuery = graphql`
query BlogPostByPath($path: String!) { query BlogPostBySlug($slug: String!) {
site { site {
siteMetadata { siteMetadata {
title title
author author
} }
} }
markdownRemark(frontmatter: { path: { eq: $path } }) { markdownRemark(fields: { slug: { eq: $slug } }) {
id id
html html
frontmatter { frontmatter {