hornwitser.no/content/links.tsx

43 lines
888 B
TypeScript
Raw Normal View History

2025-01-25 10:46:08 +01:00
import { readFileSync } from "node:fs";
import { BasePage } from "./bases.js";
import type { Page } from "./types.js";
interface LinkData {
title: string,
url: string,
tags: string[],
description?: string,
read?: string,
author?: string,
}
interface Data {
links: LinkData[];
to_read: string[],
authors: Record<string, {
urls: string[],
}>;
}
function Link(props: { link: LinkData }) {
const link = props.link;
return <>
<a href={link.url}>{link.title}</a>
{" "}
{link.tags.join(", ")}
</>
}
const data: Data = eval(`(${readFileSync("content/links.jsonc", "utf8")})`);
data.links.pop(); // Remove template at the end
const title = "Links!";
export const links: Page = {
title,
ref: "/links.html",
content: <BasePage title={title}>
<main>
<h1>{title}</h1>
<ul>
{ data.links.map(link => <li><Link link={link} /></li>)}
</ul>
</main>
</BasePage>
}