Update slug format for post type

Posts no longer need to specify a full url for the resulting html.
Rather, the prefix portion of the url will be inferred from the
post's location in the source filesystem. The post slug now simply
represents a url friendly version of the title.

Additionally, updates all sample posts to use the new slug format.
This commit is contained in:
Robert Veitch
2019-12-11 22:27:28 -06:00
parent b87a500b30
commit f2721c4542
6 changed files with 7 additions and 6 deletions

View File

@@ -8,10 +8,11 @@ const onCreateNode = ({ node, actions, getNode }) => {
if (node.internal.type === 'MarkdownRemark') {
if (typeof node.frontmatter.slug !== 'undefined') {
const dirname = getNode(node.parent).relativeDirectory;
createNodeField({
node,
name: 'slug',
value: node.frontmatter.slug
value: `/${dirname}/${node.frontmatter.slug}`
});
} else {
const value = createFilePath({ node, getNode });