motto/src/app/[...file]/page.tsx

71 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-09-16 19:44:19 +00:00
import type { Metadata, ResolvingMetadata } from 'next';
import Image from 'next/image';
import Content from './content';
import {
root,
center,
title_group,
title_text_group,
supertitle,
title,
download_button,
download_button_image,
download_text_section,
download_text,
} from './page.css';
import download_image from './download.png';
type SearchParams = { [key: string]: string | string[] | undefined };
type Props = {
params: { file: string },
searchParams: SearchParams,
};
2024-09-16 19:57:33 +00:00
function get_path(file: string[]) {
return file.join("/");
}
2024-09-16 19:44:19 +00:00
function get_root(search_params: SearchParams) {
console.log("HEEEERORORORRO", search_params)
return search_params['root'] ?? 'raw.monodon.me';
}
export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata,
): Promise<Metadata> {
return {
2024-09-16 19:57:33 +00:00
title: `${get_path(params.file)} | ${get_root(searchParams)}`,
2024-09-16 19:44:19 +00:00
};
}
export default async function Page({
params, searchParams
}: Props) {
2024-09-16 19:57:33 +00:00
const path = get_path(params.file);
2024-09-16 19:44:19 +00:00
const root_url = `https://${get_root(searchParams)}/`;
return (
<div className={root}>
<div className={center}>
<div className={title_group}>
<div className={title_text_group}>
<p className={supertitle}>{root_url}</p>
2024-09-16 19:57:33 +00:00
<p className={title}>{path}</p>
2024-09-16 19:44:19 +00:00
</div>
<button className={download_button}>
<Image
className={download_button_image}
src={download_image}
alt="Download Button"
/>
</button>
</div>
2024-09-16 19:57:33 +00:00
<Content src={`${root_url}${path}`} />
2024-09-16 19:44:19 +00:00
</div>
</div>
);
}