Here I blog about whatever get my attention
{posts.length > 0 ? (
- posts.map((post, i) =>
)
+
+ {posts.map((post, i) => (
+
+ ))}
+
) : (
)}
diff --git a/app/routes/blog/route.tsx b/app/routes/blog/route.tsx
index e4907fc..616892a 100644
--- a/app/routes/blog/route.tsx
+++ b/app/routes/blog/route.tsx
@@ -4,9 +4,8 @@ import { LinkWrapper } from "~/components/LinkWrapper";
import { useMatch } from "./useMatch";
export default function () {
- const { handle } = useMatch() as unknown as {
- handle: { to: string; text: string };
- };
+ const { handle } = useMatch();
+
return (
diff --git a/app/routes/blog/useMatch.ts b/app/routes/blog/useMatch.ts
index 6514090..3709fcb 100644
--- a/app/routes/blog/useMatch.ts
+++ b/app/routes/blog/useMatch.ts
@@ -8,5 +8,7 @@ export function useMatch() {
throw new Error("Bruh");
}
- return { handle, ...rest};
+ return { handle, ...rest } as unknown as {
+ handle: { to: string; text: string };
+ };
}
diff --git a/app/utils/posts.server.ts b/app/utils/posts.server.ts
index 70ef9f8..dcef720 100644
--- a/app/utils/posts.server.ts
+++ b/app/utils/posts.server.ts
@@ -6,7 +6,7 @@ import path from "path";
type FrontMatter = {
title: string;
description: string;
- published: string;
+ published: Date;
isFeatured: boolean;
};
@@ -34,11 +34,14 @@ export const getMdxFile = async (file: string) => {
});
};
+export type Post = Omit & {
+ filename: string;
+ published: string;
+};
+
export const findPosts = async () => {
const files = await readdir(`posts`);
- const posts: (FrontMatter & {
- filename: string;
- })[] = [];
+ const posts: Post[] = [];
for (const file of files.filter((file) => file.endsWith(".mdx"))) {
const filePath = path.join(process.cwd(), `posts/${file}`);
const { frontmatter } = await bundleMDX({
@@ -61,8 +64,9 @@ export const findPosts = async () => {
});
posts.push({
- filename: file.replace(".mdx", ""),
...frontmatter,
+ filename: file.replace(".mdx", ""),
+ published: frontmatter.published.toISOString(),
});
}