diff --git a/.gitignore b/.gitignore index 5806ad7..bf7ca77 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,4 @@ node_modules /.cache /build /public/build -.env - -# TODO: remove the following line -posts/*.mdx \ No newline at end of file +.env \ No newline at end of file diff --git a/app/routes/blog._index/EmptyState.tsx b/app/routes/blog._index/EmptyState.tsx index 5256a8c..a9af499 100644 --- a/app/routes/blog._index/EmptyState.tsx +++ b/app/routes/blog._index/EmptyState.tsx @@ -1,6 +1,6 @@ export function EmptyState() { return ( -
+
I haven't post anything yet! So here's a pic of my cat
diff --git a/app/routes/blog._index/Post.tsx b/app/routes/blog._index/Post.tsx index 058e897..7b15f5a 100644 --- a/app/routes/blog._index/Post.tsx +++ b/app/routes/blog._index/Post.tsx @@ -3,11 +3,11 @@ import { Link } from "@remix-run/react"; type PostProps = { filename: string; title: string; - publishedAt: string; + published: string; description: string | null; }; -export function Post({ title, description, filename, publishedAt }: PostProps) { +export function Post({ title, description, filename, published }: PostProps) { return (
@@ -17,7 +17,7 @@ export function Post({ title, description, filename, publishedAt }: PostProps) { {title} {`(${new Date( - publishedAt + published ).toLocaleDateString()})`}
{description && ( diff --git a/app/utils/posts.server.ts b/app/utils/posts.server.ts index 5c6a9ea..49f93cd 100644 --- a/app/utils/posts.server.ts +++ b/app/utils/posts.server.ts @@ -6,15 +6,17 @@ import codeHikeTheme from "shiki/themes/one-dark-pro.json"; type FrontMatter = { title: string; description: string; - publishedAt: string; + published: string; }; export const getMdxFile = async (file: string) => { return bundleMDX({ source: (await readFile(`./posts/${file}.mdx`)).toString(), - mdxOptions() { + mdxOptions(options) { return { + rehypePlugins: [...(options.rehypePlugins ?? [])], remarkPlugins: [ + ...(options.remarkPlugins ?? []), [ remarkCodeHike, { @@ -36,7 +38,7 @@ export const findPosts = async () => { filename: string; })[] = []; for (const file of files.filter((file) => file.endsWith(".mdx"))) { - const { frontmatter } = await bundleMDX({ + const { frontmatter } = await bundleMDX({ source: (await readFile(`./posts/${file}`)).toString(), mdxOptions() { return { @@ -59,11 +61,11 @@ export const findPosts = async () => { filename: file.replace(".mdx", ""), description: frontmatter.description, title: frontmatter.title, - publishedAt: frontmatter.publishedAt, + published: frontmatter.published, }); } return posts.sort((a, b) => - new Date(a.publishedAt) > new Date(b.publishedAt) ? -1 : 1 + new Date(a.published) > new Date(b.published) ? -1 : 1 ); }; diff --git a/posts/.gitkeep b/posts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/posts/helloworld.mdx b/posts/helloworld.mdx new file mode 100644 index 0000000..26d783c --- /dev/null +++ b/posts/helloworld.mdx @@ -0,0 +1,18 @@ +--- +title: Hello, world +published: 2023-03-15 +description: The hello world post +--- + +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore +et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + +Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + +Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +```c +int main(int argc, char** argv) { + return 0; +} +``` \ No newline at end of file