shivam + claude changes
All checks were successful
Deploy Website / build-and-deploy (push) Successful in 28s

This commit is contained in:
Shivam Patel
2026-02-08 23:18:21 -05:00
parent 3174638dd3
commit c0ffc01b88
26 changed files with 342 additions and 86 deletions

View File

@@ -10,7 +10,6 @@ export type PostMetadata = {
description: string;
slug: string;
tags?: string[];
[key: string]: any;
};
export type Post = {
@@ -27,8 +26,20 @@ export function getPostSlugs() {
export function getPostBySlug(slug: string): Post {
const realSlug = slug.replace(/\.mdx$/, '');
if (/[\/\\]|\.\./.test(realSlug)) {
throw new Error(`Invalid slug: ${realSlug}`);
}
const fullPath = path.join(postsDirectory, `${realSlug}.mdx`);
const fileContents = fs.readFileSync(fullPath, 'utf8');
let fileContents: string;
try {
fileContents = fs.readFileSync(fullPath, 'utf8');
} catch {
throw new Error(`Post not found: ${realSlug}`);
}
const { data, content } = matter(fileContents);
return {