Catch all subpaths

This commit is contained in:
Gnarwhal 2024-09-16 19:57:33 +00:00
parent 2c2fd045b3
commit 13c9a7140c
Signed by: Gnarwhal
GPG key ID: 0989A73D8C421174
10 changed files with 21 additions and 8 deletions

View file

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -23,6 +23,10 @@ type Props = {
searchParams: SearchParams, searchParams: SearchParams,
}; };
function get_path(file: string[]) {
return file.join("/");
}
function get_root(search_params: SearchParams) { function get_root(search_params: SearchParams) {
console.log("HEEEERORORORRO", search_params) console.log("HEEEERORORORRO", search_params)
return search_params['root'] ?? 'raw.monodon.me'; return search_params['root'] ?? 'raw.monodon.me';
@ -33,13 +37,14 @@ export async function generateMetadata(
parent: ResolvingMetadata, parent: ResolvingMetadata,
): Promise<Metadata> { ): Promise<Metadata> {
return { return {
title: `${params.file} | ${get_root(searchParams)}`, title: `${get_path(params.file)} | ${get_root(searchParams)}`,
}; };
} }
export default async function Page({ export default async function Page({
params, searchParams params, searchParams
}: Props) { }: Props) {
const path = get_path(params.file);
const root_url = `https://${get_root(searchParams)}/`; const root_url = `https://${get_root(searchParams)}/`;
return ( return (
@ -48,7 +53,7 @@ export default async function Page({
<div className={title_group}> <div className={title_group}>
<div className={title_text_group}> <div className={title_text_group}>
<p className={supertitle}>{root_url}</p> <p className={supertitle}>{root_url}</p>
<p className={title}>{params.file}</p> <p className={title}>{path}</p>
</div> </div>
<button className={download_button}> <button className={download_button}>
<Image <Image
@ -58,7 +63,7 @@ export default async function Page({
/> />
</button> </button>
</div> </div>
<Content src={`${root_url}${params.file}`} /> <Content src={`${root_url}${path}`} />
</div> </div>
</div> </div>
); );

View file

@ -0,0 +1,6 @@
import { style } from '@vanilla-extract/css'
export const text = style({
fontFamily: 'monospace',
whiteSpace: 'pre-wrap',
});

View file

@ -0,0 +1,7 @@
import * as style from './text.css'
export default function Text({ text }: { text: string }) {
return (
<p className={style.text}>{text}</p>
);
}

View file

@ -1,5 +0,0 @@
export default function Text({ text }: { text: string }) {
return (
<p>{text}</p>
);
}