-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathindex.page.ts
More file actions
54 lines (48 loc) · 1.47 KB
/
index.page.ts
File metadata and controls
54 lines (48 loc) · 1.47 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
export const layout = "layout.tsx";
export const title = "Ryan Dahl";
export const url = "/";
export default function* ({ search }: { search: any }) {
const allPages = search.pages();
const posts = allPages
.filter((page: any) => page.title && page.publish_date)
.sort((a: any, b: any) =>
new Date(b.publish_date).getTime() - new Date(a.publish_date).getTime()
);
const content = `
<div class="header">
<img src="/ry.jpg" alt="Ryan Dahl" class="avatar">
<div class="header-content">
<h1 class="site-title">Ryan Dahl</h1>
<div class="links">
<a href="mailto:ry@tinyclouds.org">Email</a>
<a href="https://github.com/ry">GitHub</a>
<a href="https://twitter.com/rough__sea">Twitter</a>
<a href="/feed">RSS</a>
</div>
<button class="theme-toggle" onclick="toggleTheme()">🌓</button>
</div>
</div>
<ul class="post-list">
${
posts.map((post: any) => {
const formattedDate =
new Date(post.publish_date).toISOString().split("T")[0];
// Fix the URL to remove /posts/ prefix
const cleanUrl = post.url.replace("/posts/", "/");
return `
<li>
<h2><a href="${cleanUrl}">${post.title}</a></h2>
<div class="post-date">${formattedDate}</div>
</li>
`;
}).join("")
}
</ul>
`;
yield {
url: "/",
title: "Ryan Dahl",
layout: "layout.tsx",
content: content,
};
}