Hello and welcome to Daily Two Cents. Today I'm going to be going over my portfolio site a bit. I have to update both that and my resume so I'd figure I'd just talk about

I used Gatsby to create my portfolio site. As I mentioned before, I enjoy using new technologies for my side projects and I chose Gatsby for this one.

One thing that I'm proud of is using the Gatsby plugin gatsby-source-filesystem, which allows me to go through each of the files in a designated folder, in this case the projects folder.

> projects
  - bujo.md
  - penny.md
  - portfolio.md

So the plugin, with some custom code goes through each file, checks if it's a markdown file and then creates a slug for it, so I can reference it later. This uses the createNodeField method from the plugin that I'm using, as you can see below

const { createFilePath } = require(`
gatsby-source-filesystem
`)
exports.onCreateNode = ({ node, getNode, actions }) => {
  const { createNodeField } = actions
  if (node.internal.type === `
MarkdownRemark
`) {
    const slug = createFilePath({ node, getNode, basePath: `
pages
` })
    createNodeField({
      node,
      name: `
slug
`,
      value: slug,
    })
  }
}

Then for each slug that is created, I can create a page for that slug, allowing my to manage my projects with just markdown files. For creating pages I use the createPage method.

exports.createPages = async ({ graphql, actions }) => {
  const { createPage } = actions
  const result = await graphql(`
...
`)
  result.data.allMarkdownRemark.edges.forEach(({ node }) => {
    createPage({
      path: node.fields.slug,
      component: path.resolve(`
./src/templates/project-post.js
`),
      context: {
        // Data passed to context is available
        // in page queries as GraphQL variables.
        slug: node.fields.slug,
      },
    })
  })
}

I use graphql to get the slugs and then create the pages using those files. The files themselves are relatively simple. I include data in the frontmatter of the markdown file which includes everything I need.

---

index: 1
title: Penny
startDate: "2020-06-11"
dark:
image: /contactkeeper.jpg
live: https://penny.centanomics.repl.co/
repo: https://github.com/centanomics/Penny
description: Featured Project

---

And the rest of the markdown file is just regular Markdown that is converted to html using a template I created. I mainly use it to show all of my projects on the main page though. Also, before I forget, you can checkout all of the code for what I just talked about here

I'm going to sign off here and focus more on polishing this site, so I'll see you guys tomorrow!

This post is also available on DEV.