Skip to content

Commit

Permalink
fix blog post bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nicosalm committed Feb 6, 2025
1 parent 9161841 commit f27f327
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
20 changes: 20 additions & 0 deletions src/pages/404.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
import Layout from "../layouts/Layout.astro";
---

<Layout>
<div class="max-w-4xl mx-auto px-4 py-16">
<h1 class="text-4xl font-bold text-center mb-4">Page Not Found</h1>
<p class="text-lg text-gray-600 text-center mb-8">
The page you're looking for doesn't exist or has been moved.
</p>
<div class="text-center">
<a
href="/"
class="inline-block bg-red-500 text-white px-6 py-2 rounded hover:bg-red-600"
>
Go Home
</a>
</div>
</div>
</Layout>
10 changes: 5 additions & 5 deletions src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { CollectionEntry, getCollection } from 'astro:content';
import BlogPost from '../../layouts/BlogPost.astro';
export async function getStaticPaths() {
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug },
props: post,
}));
const posts = await getCollection('blog');
return posts.map((post) => ({
params: { slug: post.slug + '.html' },
props: post,
}));
}
type Props = CollectionEntry<'blog'>;
Expand Down
28 changes: 18 additions & 10 deletions src/utils/redirects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,29 @@ function getAllMarkdownFiles(dirPath: string, arrayOfFiles: string[] = []): stri

export function generateResourceRedirects() {
const redirects: Record<string, string> = {
// existing static redirects
"/hours.html": "/hours",
"/blog.html": "/blog",
"/coords": "/about",
"/2022/02/25/incorrect-reification.html": "/blog/incorrect-reification/",
"/2022/02/02/learning-to-code-with-projects.html": "/blog/learning-to-code-with-projects/",
"/2022/02/09/a-cautionary-tale-of-amazon-web-service-classes.html": "/blog/a-cautionary-tale-of-amazon-web-service-classes/",
"/2022/03/17/exploiting-github-actions.html": "/blog/exploiting-github-actions/",
"/2022/04/03/why-i-use-firefox.html": "/blog/why-i-use-firefox/",
"/2022/04/16/Game-Design-and-Education.html": "/blog/game-design-and-education/",
"/2022/04/7/Artificial-Consciousness-and-Phenomenology.html": "/blog/artificial-consciousness-and-phenomenology/",
"/2022/05/12/Using-GPT3-To-Write-A-Blog-Post.html": "/blog/using-gpt3-to-write-a-blog-post/",

"/2022/02/25/incorrect-reification.html": "/blog/incorrect-reification.html",
"/2022/02/02/learning-to-code-with-projects.html": "/blog/learning-to-code-with-projects.html",
"/2022/02/09/a-cautionary-tale-of-amazon-web-service-classes.html": "/blog/a-cautionary-tale-of-amazon-web-service-classes.html",
"/2022/03/17/exploiting-github-actions.html": "/blog/exploiting-github-actions.html",
"/2022/04/03/why-i-use-firefox.html": "/blog/why-i-use-firefox.html",
"/2022/04/16/Game-Design-and-Education.html": "/blog/game-design-and-education.html",
"/2022/04/7/Artificial-Consciousness-and-Phenomenology.html": "/blog/artificial-consciousness-and-phenomenology.html",
"/2022/05/12/Using-GPT3-To-Write-A-Blog-Post.html": "/blog/using-gpt3-to-write-a-blog-post.html",

"/blog/incorrect-reification": "/blog/incorrect-reification.html",
"/blog/learning-to-code-with-projects": "/blog/learning-to-code-with-projects.html",
"/blog/a-cautionary-tale-of-amazon-web-service-classes": "/blog/a-cautionary-tale-of-amazon-web-service-classes.html",
"/blog/exploiting-github-actions": "/blog/exploiting-github-actions.html",
"/blog/why-i-use-firefox": "/blog/why-i-use-firefox.html",
"/blog/game-design-and-education": "/blog/game-design-and-education.html",
"/blog/artificial-consciousness-and-phenomenology": "/blog/artificial-consciousness-and-phenomenology.html",
"/blog/using-gpt3-to-write-a-blog-post": "/blog/using-gpt3-to-write-a-blog-post.html",
};

// get all markdown files from the resources dir & add redirects to each
const contentDir = path.join(process.cwd(), 'src/content/resources');
const markdownFiles = getAllMarkdownFiles(contentDir);

Expand Down

1 comment on commit f27f327

@nicosalm
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this did not work :/ -- but now we have a 404 page! fix of fix coming soon

Please sign in to comment.