DEV Community

Cover image for Daily Two Cents - Portfolio
Cent | Shannon Myers
Cent | Shannon Myers

Posted on

Daily Two Cents - Portfolio

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
Enter fullscreen mode Exit fullscreen mode

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` })
      name: `slug`,
      value: slug,
Enter fullscreen mode Exit fullscreen mode

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(`...`){ node }) => {
      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,
Enter fullscreen mode Exit fullscreen mode

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"
image: /contactkeeper.jpg
description: "Featured Project"

Enter fullscreen mode Exit fullscreen mode

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!

Discussion (0)