46 lines
1.1 KiB
TypeScript
46 lines
1.1 KiB
TypeScript
|
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>
|
||
|
);
|
||
|
}
|