Move posts to separate folder, update URLs to use slugs

This commit is contained in:
Cassidy Williams
2022-08-26 00:36:03 -05:00
parent 463ee505e8
commit 32425613cd
32 changed files with 53 additions and 59 deletions

View File

@@ -4,7 +4,7 @@ const { slug, title, tags, description, date } = Astro.props;
---
<li>
<a href={`/${slug}/`} class="title">{title}</a>
<a href={`/post/${slug}/`} class="title">{title}</a>
<time datetime={date}>
{new Date(date).toLocaleDateString('en-us', {
year: 'numeric',

View File

@@ -1,14 +0,0 @@
---
// Credit to @rachsmithcodes for this function
export async function getStaticPaths() {
let posts = await Astro.glob(`./posts/*.md`);
return posts.map((post) => ({
params: { slug: post.frontmatter.slug },
props: { post: post },
}));
}
---
hey

View File

@@ -0,0 +1,23 @@
---
// Credit to @rachsmithcodes for this function
export async function getStaticPaths() {
let posts = await Astro.glob(`../../posts/*.md`);
return posts.map((post) => {
return ({
params: { slug: post.frontmatter.slug },
props: { post: post },
})
});
}
const { post } = Astro.props;
const {
Content,
frontmatter: { title, added, updated, tags, excerpt },
} = post;
---
<Content />

View File

@@ -7,7 +7,7 @@ import Post from '../components/Post.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
// Use Astro.glob() to fetch all posts, and then sort them by date.
const posts = (await Astro.glob('./post/*.{md,mdx}')).sort(
const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
(a, b) => new Date(b.frontmatter.added).valueOf() - new Date(a.frontmatter.added).valueOf()
);
---
@@ -34,21 +34,6 @@ const posts = (await Astro.glob('./post/*.{md,mdx}')).sort(
<main>
<content>
<ul>
{posts.map((post) => (
<li>
<time datetime={post.frontmatter.added}>
{new Date(post.frontmatter.added).toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: 'numeric',
})}
</time>
<a href={post.url}>{post.frontmatter.title}</a>
</li>
))}
</ul>
<ul>
{posts.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
<Post {url} {description} {date} {slug} {title} {tags} />

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "10 Tips for Successful Public Speaking"
slug: public-speaking
description: "Public speaking is the number 1 fear out there. Let's conquer it together. Lovingly."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "5 applications of linear regression that will drive him crazy"
slug: linear-regression
description: "Push these sexy applications in his mind to spice things up and drive him nuts."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "A Weekend at BattleHack Boston"
slug: battlehack-boston
description: "I had my first hackathon experience as a Venmo employee this past weekend, and boy was it fun!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Adding Keyboard Shortcuts to your React Apps"
slug: keyboard-shortcuts-react
description: "Using the Mousetrap library, you can add keyboard shortcuts to your React apps."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Writing Practice: The Agua Caliente Airport"
slug: agua-caliente
description: "I did a writing exercise using a random Wikipedia page. And puns."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Building My S60-X Keyboard"
slug: s60x-keyboard
description: "After a bunch of trial and error, I built and programmed my first mechanical keyboard!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Closures in JavaScript"
slug: closures-in-js
description: "Closures in JavaScript are an important concept that all JS devs should know. So here's a summary for you."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Crushing the Impostor Syndrome"
slug: impostor-syndrome
description: "Sometimes you don't feel like you're good enough, and that you're fooling everyone. You're not alone."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "The CSS Image Values Spec"
slug: css-image-values
description: "The CSS Image Values Spec allows you to cleanly blow up pixel art on the web."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Pure CSS3 Text Carousel"
slug: css-text-carousel
description: "I built a pure CSS text carousel because I couldn't find one I liked. Here's how I did it, and tweaks for later."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Feedback is awesome"
slug: feedback-is-awesome
description: "I love getting feedback from people. You learn most from it."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Finding a Mentor"
slug: finding-a-mentor
description: "Finding a mentor isn't always as explicit as it seems."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Hello, world"
slug: hello-world
description: "Lorem ipsum dolor sit amet"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "How to Ace an Interview"
slug: ace-interview
description: "Interviews are scary, but they don't have to be. When you're on the spot, it's best to be prepared. Let's prepare you."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "How to ask for help"
slug: ask-for-help
description: "Some people don't know how to ask for help. Luckily, there's a proper way to do it."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "HTML+CSS Tutorial, Part 2"
slug: html-css-part-2
description: "This is part 2 of a two-part tutorial for beginners as an introduction to HTML and CSS."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "HTML+CSS Tutorial, Part 1"
slug: html-css-part-1
description: "This is part 1 of a two-part tutorial for beginners as an introduction to HTML and CSS."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "L4 Digital: First Impressions"
slug: l4-digital-first-week
description: "This week was my first week at L4 Digital!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Making the Whitney Houston API"
slug: whitney-houston-api
description: "I made a Whitney Houston API. Because why not."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Messing with Sketch Club"
slug: trying-sketch-club
description: "I got the app Sketch Club and have really enjoyed making some fun drawings!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "My last days at ISU"
slug: bye-isu
description: "I'm leaving Iowa State in a few weeks, which is both a bummer and very exciting."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "My Talk at TEDxDesMoines"
slug: tedx-talk
description: "I talked at TEDxDesMoines, come here what I had to say! If you want to, of course."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "One year at Venmo"
slug: one-year-at-venmo
description: "I've been at Venmo for a year!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Picking your brain: Cold call email etiquette"
slug: cold-call-email
description: 'I get a LOT of emails from people asking to "pick my brain." Here is how I wish people would approach this.'

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Subconscious Learning"
slug: subconscious-learning
description: "I've been learning about... learning lately, specifically subconscious learning. Here's what I've found!"

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "A Brief History of the PNG"
slug: png-history
description: "The PNG file format has been around forever... sort of. Not really."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "The laptop you need for college"
slug: college-laptop
description: "Too often people go for the biggest and best laptop out there, when there are reasonable, affordable options. Let's talk about it."

View File

@@ -1,5 +1,5 @@
---
layout: "../../layouts/BlogPost.astro"
layout: "../layouts/BlogPost.astro"
title: "Things you should have on your LinkedIn profile"
slug: linkedin-profile
description: "As much as I'd like to say that your looks will get you far, sometimes actual information is good to know too."