Skip to content

Commit a35663e

Browse files
committed
update
1 parent 5d7364e commit a35663e

7 files changed

Lines changed: 73 additions & 111 deletions

File tree

.astro/data-store.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

astro.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import react from "@astrojs/react";
22
import tailwindcss from "@tailwindcss/vite";
33
import { defineConfig } from "astro/config";
4+
import remarkGfm from "remark-gfm";
45

56
// https://astro.build/config
67
export default defineConfig({
78
integrations: [react()],
9+
markdown: {
10+
remarkPlugins: [remarkGfm],
11+
},
812
vite: {
913
plugins: [tailwindcss()],
1014
},

bun.lock

Lines changed: 1 addition & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"lucide-react": "^0.545.0",
2727
"react": "^19.2.3",
2828
"react-dom": "^19.2.3",
29-
"react-markdown": "^10.1.0",
29+
"remark-gfm": "^4.0.1",
3030
"tailwind-merge": "^3.3.1"
3131
},
3232
"devDependencies": {

src/components/blog/blog-post.tsx

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ArrowLeft } from "lucide-react";
2-
import ReactMarkdown, { type Components } from "react-markdown";
2+
import type { ReactNode } from "react";
33
import { AppLink } from "@/components/app-link";
44
import { Badge } from "@/components/ui/badge";
55
import { Button } from "@/components/ui/button";
@@ -13,12 +13,12 @@ export interface BlogPostData {
1313
publishedAt: string | Date;
1414
tags: string[];
1515
readingMinutes: number;
16-
content: string;
1716
}
1817

1918
interface Props {
2019
post: BlogPostData;
2120
className?: string;
21+
children?: ReactNode;
2222
}
2323

2424
function formatDate(iso: string | Date) {
@@ -31,70 +31,7 @@ function formatDate(iso: string | Date) {
3131
}).format(date);
3232
}
3333

34-
const markdownComponents: Components = {
35-
h2: ({ children }) => (
36-
<h2 className="text-2xl md:text-3xl font-display font-bold tracking-tight mt-10 mb-4 text-balance">
37-
{children}
38-
</h2>
39-
),
40-
p: ({ children }) => (
41-
<p className="text-foreground/90 text-lg leading-relaxed mb-6">
42-
{children}
43-
</p>
44-
),
45-
blockquote: ({ children }) => (
46-
<blockquote className="pl-6 border-l-2 border-primary my-8 italic text-lg text-foreground/80">
47-
{children}
48-
</blockquote>
49-
),
50-
ul: ({ children }) => (
51-
<ul className="space-y-2 pl-5 list-disc text-foreground/90 text-lg leading-relaxed mb-6 marker:text-primary/50">
52-
{children}
53-
</ul>
54-
),
55-
ol: ({ children }) => (
56-
<ol className="space-y-2 pl-5 list-decimal text-foreground/90 text-lg leading-relaxed mb-6 marker:text-primary/50">
57-
{children}
58-
</ol>
59-
),
60-
code: ({ className, children, ...props }) => {
61-
const match = /language-(\w+)/.exec(className || "");
62-
const isBlock = !!match || (children as string)?.includes?.("\n");
63-
64-
if (!isBlock && !match) {
65-
return (
66-
<code
67-
className="bg-secondary px-1.5 py-0.5 rounded-md font-mono text-sm"
68-
{...props}
69-
>
70-
{children}
71-
</code>
72-
);
73-
}
74-
75-
return (
76-
<div className="code-panel rounded-xl overflow-hidden my-8">
77-
<div className="code-panel__header px-4 py-3 flex items-center justify-between select-none">
78-
<div className="flex items-center gap-1.5">
79-
<div className="code-panel__dot code-panel__dot--1" />
80-
<div className="code-panel__dot code-panel__dot--2" />
81-
<div className="code-panel__dot code-panel__dot--3" />
82-
</div>
83-
<span className="code-panel__filename text-xs font-mono opacity-80">
84-
{match ? match[1] : "text"}
85-
</span>
86-
</div>
87-
<pre className="code-panel__content p-5 overflow-x-auto text-sm md:text-[13px] leading-relaxed font-mono">
88-
<code className={className} {...props}>
89-
{children}
90-
</code>
91-
</pre>
92-
</div>
93-
);
94-
},
95-
};
96-
97-
export function BlogPost({ post, className }: Props) {
34+
export function BlogPost({ post, className, children }: Props) {
9835
return (
9936
<div className={cn("relative z-10", className)}>
10037
{/* Subtle blur backdrop - reduced opacity to let background show through */}
@@ -134,10 +71,8 @@ export function BlogPost({ post, className }: Props) {
13471
</p>
13572
</header>
13673

137-
<article className="space-y-2 pb-20 max-w-[680px] mx-auto">
138-
<ReactMarkdown components={markdownComponents}>
139-
{post.content}
140-
</ReactMarkdown>
74+
<article className="blog-markdown pb-20 max-w-[680px] mx-auto">
75+
{children}
14176
</article>
14277

14378
<div className="border-t border-border/70 pt-10 pb-16">

src/index.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,59 @@
336336
.code-panel__dot--3 {
337337
background: var(--code-dot-3);
338338
}
339+
340+
.blog-markdown {
341+
overflow-x: auto;
342+
}
343+
344+
.blog-markdown h2 {
345+
@apply text-2xl md:text-3xl font-display font-bold tracking-tight mt-10 mb-4 text-balance;
346+
}
347+
348+
.blog-markdown p {
349+
@apply text-foreground/90 text-lg leading-relaxed mb-6;
350+
}
351+
352+
.blog-markdown blockquote {
353+
@apply pl-6 border-l-2 border-primary my-8 italic text-lg text-foreground/80;
354+
}
355+
356+
.blog-markdown ul {
357+
@apply space-y-2 pl-5 list-disc text-foreground/90 text-lg leading-relaxed mb-6 marker:text-primary/50;
358+
}
359+
360+
.blog-markdown ol {
361+
@apply space-y-2 pl-5 list-decimal text-foreground/90 text-lg leading-relaxed mb-6 marker:text-primary/50;
362+
}
363+
364+
.blog-markdown code {
365+
@apply bg-secondary px-1.5 py-0.5 rounded-md font-mono text-sm;
366+
}
367+
368+
.blog-markdown pre code {
369+
@apply bg-transparent p-0;
370+
}
371+
372+
.blog-markdown pre {
373+
@apply my-8 rounded-xl border border-border p-5 overflow-x-auto text-sm md:text-[13px] leading-relaxed font-mono;
374+
background: var(--code-bg);
375+
color: var(--code-text);
376+
}
377+
378+
.blog-markdown table {
379+
@apply my-8 w-full text-sm;
380+
border-collapse: collapse;
381+
}
382+
383+
.blog-markdown th,
384+
.blog-markdown td {
385+
@apply border border-border px-3 py-2 align-top;
386+
}
387+
388+
.blog-markdown thead th {
389+
@apply bg-secondary/60 font-semibold;
390+
}
391+
392+
.blog-markdown tbody tr:nth-child(even) td {
393+
@apply bg-muted/30;
394+
}

src/pages/blog/[...slug].astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ const { post } = Astro.props;
1515
const readingMinutes =
1616
post.data.readingMinutes || Math.ceil(post.body.split(/\s+/).length / 200);
1717
18+
const { Content } = await post.render();
19+
1820
const formattedPost = {
1921
slug: post.slug,
2022
title: post.data.title,
2123
description: post.data.description,
2224
publishedAt: post.data.publishedAt,
2325
tags: post.data.tags,
2426
readingMinutes,
25-
content: post.body,
2627
};
2728
---
2829

2930
<Layout title={post.data.title}>
30-
<BlogPost post={formattedPost} />
31+
<BlogPost post={formattedPost}>
32+
<Content />
33+
</BlogPost>
3134
</Layout>

0 commit comments

Comments
 (0)