-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathpost.tsx
More file actions
40 lines (35 loc) · 922 Bytes
/
post.tsx
File metadata and controls
40 lines (35 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
export const layout = "layout.tsx";
export default function Post(
{ title, publish_date, cover_html, post_class, children }: {
title: string;
publish_date: Date;
cover_html?: string;
post_class?: string;
children: unknown;
},
) {
const formattedDate = new Date(publish_date).toISOString().split("T")[0];
return (
<>
<div class="header">
<a href="/" class="back-button">← Back</a>
<button type="button" class="theme-toggle" onclick="toggleTheme()">
🌓
</button>
</div>
{cover_html && (
<div
class="post-cover"
dangerouslySetInnerHTML={{ __html: cover_html }}
/>
)}
<h1 class="post-title">{title}</h1>
<div class="post-meta">
{formattedDate}
</div>
<div class={`content${post_class ? ` ${post_class}` : ""}`}>
{children}
</div>
</>
);
}