Add friendly aliases for client proofing links
This commit is contained in:
54
app/c/[alias]/page.tsx
Normal file
54
app/c/[alias]/page.tsx
Normal file
@@ -0,0 +1,54 @@
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
|
||||
import { findSessionByAlias } from '@/lib/proofSessions';
|
||||
import {
|
||||
proofMetadata,
|
||||
renderProof,
|
||||
} from '../../proof/renderProof';
|
||||
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
|
||||
|
||||
interface ClientPageProps {
|
||||
params: Promise<{
|
||||
alias: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
|
||||
export async function generateMetadata({
|
||||
params,
|
||||
}: ClientPageProps): Promise<Metadata> {
|
||||
const { alias } = await params;
|
||||
|
||||
const session = await findSessionByAlias(alias);
|
||||
|
||||
if (!session) {
|
||||
return {
|
||||
title: 'Not found',
|
||||
robots: {
|
||||
index: false,
|
||||
follow: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return proofMetadata(session.token);
|
||||
}
|
||||
|
||||
|
||||
export default async function ClientPage({
|
||||
params,
|
||||
}: ClientPageProps) {
|
||||
const { alias } = await params;
|
||||
|
||||
const session = await findSessionByAlias(alias);
|
||||
|
||||
if (!session) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return renderProof(session.token);
|
||||
}
|
||||
Reference in New Issue
Block a user