78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { Metadata } from "next";
|
|
import Link from "next/link";
|
|
|
|
import { getArtifacts } from "@utils";
|
|
|
|
import styles from "./page.module.css";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "ryan christoffersen | artifacts",
|
|
};
|
|
|
|
async function getArtifactsByGroup() {
|
|
return [
|
|
{
|
|
group: "essays",
|
|
items: getArtifacts("essays").sort((a, b) => b.order - a.order),
|
|
},
|
|
{
|
|
group: "film / videos",
|
|
items: [...getArtifacts("film"), ...getArtifacts("videos")].sort(
|
|
(a, b) => b.order - a.order,
|
|
),
|
|
},
|
|
{
|
|
group: "software",
|
|
items: getArtifacts("software").sort((a, b) => b.order - a.order),
|
|
},
|
|
];
|
|
}
|
|
|
|
const ArtifactsPage = async () => {
|
|
const artifacts = await getArtifactsByGroup();
|
|
return (
|
|
<div className={styles.container}>
|
|
<div className={styles.content}>
|
|
{!artifacts.length ? (
|
|
<p>
|
|
<i>{"failed to load artifacts"}</i>
|
|
</p>
|
|
) : (
|
|
<div>
|
|
{artifacts.map(({ group, items }) => (
|
|
<div key={group} style={{ margin: "2em 0" }}>
|
|
<h2>{group}</h2>
|
|
<ul>
|
|
{items.map(
|
|
({
|
|
id,
|
|
category,
|
|
title,
|
|
description,
|
|
created,
|
|
updated,
|
|
}) => (
|
|
<li key={id}>
|
|
<Link href={`/artifacts/` + category + "/" + id}>
|
|
<h3>{title}</h3>
|
|
<p>{description}</p>
|
|
<p>
|
|
<i>{`created: ${created.toDateString()}`}</i>
|
|
{" | "}
|
|
<i>{`updated: ${updated.toDateString()}`}</i>
|
|
</p>
|
|
</Link>
|
|
</li>
|
|
),
|
|
)}
|
|
</ul>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default ArtifactsPage;
|