This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.

46 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-24 17:46:47 +01:00
import React, { ReactElement } from "react";
import { ActionMenu } from "@/app/components/action-menu";
import { Metadata } from "next";
import { notFound } from "next/navigation";
import { Button } from "@/app/components/ui/button";
import Link from "next/link";
import {
generatePasteMetadata,
getPaste,
type Paste,
} from "@/app/common/pastes";
import { PastePageProps } from "@/app/types/paste-page";
export async function generateMetadata({
params: { id },
}: PastePageProps): Promise<Metadata> {
return generatePasteMetadata(id);
}
export default async function Paste({
params: { id },
}: PastePageProps): Promise<ReactElement> {
const data: Paste | undefined = await getPaste(id);
if (data == undefined) {
return notFound();
}
return (
<div className="relative h-full">
<ActionMenu>
<Link href={"/"}>
<Button>New</Button>
</Link>
<Link href={`/${id}`}>
<Button>Formated</Button>
</Link>
</ActionMenu>
<div className="p-1 hljs !bg-transparent text-sm">
<code>{data.content}</code>
</div>
</div>
);
}