Skip to content

Commit 867bb0f

Browse files
committed
change post into blog for posts
1 parent 49aac84 commit 867bb0f

24 files changed

+55
-40
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This repo contains my personal website including some blogs and project examples.
44

5-
Right now it's built using Nextjs for fun so I could try it out. Who knows what it evolves to next.
5+
Right now it's built using Nextjs for fun so I could try it out. Who knows what it evolves to next. It is also a little playground, so always under construction! ❤️

components/Layout/index.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export default function Layout({
99
children,
1010
breadcrumbs,
1111
socialMeta,
12-
structured
12+
structured,
13+
canonical,
14+
refreshUrl
1315
}) {
1416
return (
1517
<>
@@ -21,6 +23,18 @@ export default function Layout({
2123
{content}
2224
</script>
2325
))}
26+
{refreshUrl && (
27+
<meta
28+
httpEquiv='refresh'
29+
content={`2;url=https://khendrikse.github.io/${refreshUrl}`}
30+
/>
31+
)}
32+
{canonical && (
33+
<link
34+
rel='canonical'
35+
href={`https://khendrikse.github.io/${canonical}`}
36+
/>
37+
)}
2438
<script type='application/ld+json'>
2539
{generateBreadcrumbs(breadcrumbs)}
2640
</script>
@@ -52,5 +66,6 @@ Layout.propTypes = {
5266
type: PropTypes.string,
5367
url: PropTypes.string
5468
}),
55-
structured: PropTypes.array
69+
structured: PropTypes.array,
70+
canonical: PropTypes.string
5671
};

components/PostItem/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function PostItem({ item }) {
1111
{new Date(item.date).toDateString()}
1212
</div>
1313
<h2 className={styles.post_item__title}>
14-
<Link href={`/post/${item.slug}`}>
14+
<Link href={`/blog/${item.slug}`}>
1515
<a className={styles.post_item__title__link}>{item.title}</a>
1616
</Link>
1717
</h2>

helpers/parse-posts.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const parsePosts = context => {
1717
date
1818
};
1919
})
20-
.sort((a, b) => new Date(b.date) - new Date(a.date));
20+
.sort((a, b) => new Date(b.date) - new Date(a.date))
21+
.filter(post => post.published);
2122
return data;
2223
};
2324

next.config.js

-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ const withPlugins = require('next-compose-plugins');
22
const optimizedImages = require('next-optimized-images');
33

44
const nextConfig = {
5-
async redirects() {
6-
return [
7-
{
8-
source: '/about',
9-
destination: '/',
10-
permanent: false
11-
}
12-
];
13-
},
145
swcMinify: true,
156
images: {
167
disableStaticImages: true

pages/blog/[postname].js

+5-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ProgressiveImage from 'components/ProgressiveImage';
1313
import isExternalImage from 'helpers/is-external-image';
1414
import generateArticleStructuredData from 'helpers/generate-article-structured-data';
1515
import generateFaqStructuredData from 'helpers/generate-faq-structured-data';
16+
import parsePosts from 'helpers/parse-posts';
1617

1718
export default function BlogPost({
1819
siteTitle,
@@ -138,18 +139,11 @@ export async function getStaticProps({ ...ctx }) {
138139
}
139140

140141
export async function getStaticPaths() {
141-
const blogSlugs = (context => {
142-
const keys = context.keys();
143-
const data = keys.map(key => {
144-
const slug = key.replace(/^.*[\\/]/, '').slice(0, -3);
142+
const allPosts = parsePosts(
143+
require.context('../../posts', true, /\.\/.*\.md$/)
144+
).map(post => post.slug);
145145

146-
return slug;
147-
});
148-
149-
return data;
150-
})(require.context('../../posts', true, /\.\/.*\.md$/));
151-
152-
const paths = blogSlugs.map(slug => `/blog/${slug}`);
146+
const paths = allPosts.map(slug => `/blog/${slug}`);
153147

154148
return {
155149
paths,

pages/post/[postname].js

+9-11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ProgressiveImage from 'components/ProgressiveImage';
1313
import isExternalImage from 'helpers/is-external-image';
1414
import generateArticleStructuredData from 'helpers/generate-article-structured-data';
1515
import generateFaqStructuredData from 'helpers/generate-faq-structured-data';
16+
import parsePosts from '../../helpers/parse-posts';
1617

1718
export default function BlogPost({
1819
siteTitle,
@@ -35,10 +36,12 @@ export default function BlogPost({
3536
title: `${frontmatter.title} | ${siteTitle}`,
3637
description: frontmatter.description
3738
}}
39+
canonical={`blog/${slug}`}
3840
breadcrumbs={[
3941
{ name: 'blog', item: 'blog/' },
4042
{ name: frontmatter.title, item: `post/${slug}` }
4143
]}
44+
refreshUrl={`blog/${slug}`}
4245
structured={[
4346
generateFaqStructuredData(frontmatter.faq),
4447
generateArticleStructuredData({
@@ -138,18 +141,13 @@ export async function getStaticProps({ ...ctx }) {
138141
}
139142

140143
export async function getStaticPaths() {
141-
const blogSlugs = (context => {
142-
const keys = context.keys();
143-
const data = keys.map(key => {
144-
const slug = key.replace(/^.*[\\/]/, '').slice(0, -3);
144+
const allPosts = parsePosts(
145+
require.context('../../posts', true, /\.\/.*\.md$/)
146+
)
147+
.filter(post => post.oldBlog)
148+
.map(post => post.slug);
145149

146-
return slug;
147-
});
148-
149-
return data;
150-
})(require.context('../../posts', true, /\.\/.*\.md$/));
151-
152-
const paths = blogSlugs.map(slug => `/post/${slug}`);
150+
const paths = allPosts.map(slug => `/post/${slug}`);
153151

154152
return {
155153
paths,

posts/2019-09-17-awesome-soft-airy-and-fluffy-vsc-themes.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Awesome soft, airy and fluffy VSC themes
44
published: true
5+
oldBlog: true
56
description: These themes will lift you off for cozy coding.
67
tags: theme, vsc, pastel, productivity
78
intro: When coding I sometimes feel the need to change the aesthetics of my workspace. Why? I don't know. Maybe because it gives me a fresh look at my code. Maybe because with the seasons changing, I feel the need to lighten or darken my workspace colours. Either way, for those searching for something airy and new. Here is a list of wonderful Visual Studio Code themes that have a cozy, soft or fluffy aesthetic.

posts/2019-09-19-how-to-get-ready-for-hacktoberfest.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: How to get ready for Hacktoberfest ✨
44
published: true
5+
oldBlog: true
56
description: 5 Tips to get you ready for coding
67
intro: October is creeping closer... That means it's almost time for Hacktoberfest! Last year it was a great opportunity for me to get to know the open source community and to spend time coding something different for a change. As I enjoyed the event so much, I'd love to help others out getting a head start for this awesome month-long event!
78
tags: beginner, hacktoberfest, open-source

posts/2019-10-07-coding-with-a-group-of-11-year-olds.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Coding with a group of 11 year olds
44
published: true
5+
oldBlog: true
56
description: Get them 'hacking' their favourite websites
67
tags: beginner, teaching, tutorial, programming
78
intro: Recently a we were asked if we could give a short lesson about coding to a group of 11 year olds in primary school. So my colleague and me started preparing a 1,5 hour workshop with the goal of showing the kids how much fun programming could be. This is the story of how it went.

posts/2020-01-26-beautify-your-raspberry-pi-with-the-pimoroni-blinkt.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Beautify your Raspberry Pi with the Pimoroni Blinkt!
44
published: true
5+
oldBlog: true
56
description: Make your Raspberry Pi shine in blue and purple colors.
67
cover_image: https://thepracticaldev.s3.amazonaws.com/i/jwk9ue7pvtuj151srtod.JPG
78
cover_image_alt: a raspberry pi with shining LED lights

posts/2020-02-02-get-a-head-start-with-your-new-app-cra-custom-templates.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Get a head start with your new app - CRA custom templates
44
published: true
5+
oldBlog: true
56
description: Let's take a look at Create React App's custom templates
67
tags: #react #javascript #npm #beginner
78
intro: Create React App (CRA) already increases the speed of getting a new React app up and running. You run one script and it creates a functioning React app that you can start working on. With Custom Templates things have become even easier. In this post, we're going to discover what goes into creating a custom template.

posts/2020-02-02-light-up-leds-when-you-start-your-raspberry-pi-and-clear-them-on-shutdown.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Light up LEDs when you start your Raspberry Pi and clear them on shutdown
44
published: true
5+
oldBlog: true
56
description: Set up your Pimoroni Blinkt so it automatically turns on and off when you start-up or shut down your Raspberry Pi.
67
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/5o1drx3yby1z853rjm8d.JPG
78
cover_image_alt: a raspberry pi with blue and purple LEDs lighting up

posts/2020-02-17-personalize-your-Linux-terminal-prompt.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Personalize your Linux terminal prompt ✨
44
published: true
5+
oldBlog: true
56
description: Add your own personal touch to your Linux terminal when you're not using a GUI.
67
tags: #linux #beginner
78
intro: If you're just as much of a fan of personalizing your coding environment as I am, you must have been just as bummed out when you ran your Linux environment without a GUI and found out there was no real 'theming' going on in your terminal. No worries, there is hope!

posts/2020-05-11-redirection-and-pipeline-magic.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Redirection and pipeline magic
44
published: true
5+
oldBlog: true
56
description: For when you don't feel like diving deep into bash but do want to know what redirection is when you see it.
67
intro: Enough developers out there deliver great day-to-day work without having to touch bash whatsoever. Yet, every now and then we all encounter a piece of bash script, be it from a colleague or copied from a Stack Overflow post. Yeah, the script works, but do we understand what is happening? I wanted to know myself so I started small. Let's dive into redirection.
78
tags: #bash #linux #beginner #til

posts/2020-05-21-The-basics-of-a-function-illustrated.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: The basics of a function, illustrated! ✨
44
published: true
5+
oldBlog: true
56
description: Learn about JavaScript functions with a simple metaphor.
67
intro: One thing that can be difficult to understand when you just start out learning how to program is what a function is and how it works. As a beginner developer, it can be especially difficult to understand what arguments are and where they come from. This blog illustrates how a javascript function works in its most basic form.
78
tags: beginner, javascript, codenewbie

posts/2020-06-16-Test-global-npm-packages-in-a-quick-and-easy-way.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: Test global npm packages in a quick and easy way
44
published: true
5+
oldBlog: true
56
description: A quick guide on testing out local global npm packages line using npm or yarn.
67
intro: You might already be used to creating symlinks between projects locally using yarn or npm. But what if you are working on a cli package that you want the user to use globally? You also want to be able to test your package locally to make sure everything is working as it should. But how do you do this? Here’s an easy guide on achieving a link to a local project to test out globally in your command line using either yarn or npm.
78
tags: beginner, javascript, npm, yarn

posts/2020-12-14-how-to-stay-connected-to-your-co-workers.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: How to stay connected to your co-workers
44
published: true
5+
oldBlog: true
56
description: Staying connected in a work-from-home world
67
intro: Let’s be honest, every post nowadays starts with how weird 2020 has been. So I am doing the same; it’s been weird. There. Having been working from home full-time since March, it has been both a productivity booster and an isolating experience. Especially in the beginning.
78
tags: productivity, career, watercooler, remote

posts/2021-02-23-finding-meaning-landmarks-explained.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: 'Finding meaning: landmarks explained'
44
published: true
5+
oldBlog: true
56
description: Learning more about HTML5 elements and their landmarks
67
intro: Have you ever done a semantic html course? Or read about it? If you have, you might remember elements like <main>, <section> or maybe <aside>. But did you know that using these elements does not automatically provide the proper semantic meaning? Let's go on a journey of creating meaningful landmarks.
78
tags: accessibility, html

posts/2021-07-15-using-roadmapsh-for-structured-self-learning.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
layout: post
33
title: 'Using roadmap.sh for structured self-learning'
44
published: true
5+
oldBlog: true
56
description: These tips, tricks and resources helped me become a self-taught software developer and hopefully they can help you too.
67
intro: Three years ago I made the switch from an entirely different work field to becoming a software developer. I got lucky enough to be hired at a company that allowed me to learn on the job. Yet, I had no formal computer science education and there was no plan set up for me to structurally start learning programming. I had to devise my own. These tips, tricks and resources helped me become a self-taught software developer and hopefully they can help you too.
78
tags: beginner, programming, learning

posts/2021-08-16-get-to-know-the-terminal.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
layout: post
33
title: 'Get to know the terminal'
4-
published: false
4+
published: true
5+
oldBlog: true
56
description: Learn to understand the difference between the terminal, command line and shell. And become more comfortable using them.
67
intro: Once you start coding there will come a time you are introduced to the terminal. Opening this hacker looking window on your computer can be daunting at first. But things become less scary once we get to know the terminal better.
78
cover_image: 2021-08-16.jpg

posts/2021-08-17-9-cozy-vim-color-schemes.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
layout: post
33
title: '9 Cozy Vim color schemes'
4-
published: false
4+
published: true
5+
oldBlog: true
56
description: A list of very cozy vim color schemes.
67
intro: Ahh... to be as cozy as a cat loaf. It's hard for us humans to achieve the same comfort. But having your Vim scheme set up properly to give you a relaxed vibe might just be the next best thing. If you are looking for some cute, cozy, fluffy and pastel color schemes for Vim, you've come to the right place. Here are 9 highly curated schemes just for you.
78
cover_image: 2021-08-17.jpg

posts/2021-09-25-set-your-gatsby-develop-security-headers.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
---
22
layout: post
33
title: 'TIL: How to set security headers for Gatsby Develop'
4-
published: false
4+
published: true
5+
oldBlog: true
56
description: If, for any reason, you need to run gatsby develop and set security headers. Using advanced proxying is the way to go.
67
intro:
78
cover_image: 2021-09-25.jpg

scripts/feed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const getImageFileName = filename => {
3737
};
3838

3939
const parsePostData = (data, filename) => {
40-
const link = `https://khendrikse.github.io/post/${filename.replace(
40+
const link = `https://khendrikse.github.io/blog/${filename.replace(
4141
'.md',
4242
''
4343
)}`;

0 commit comments

Comments
 (0)