diff --git a/routes/membres/[id]/portfolio/[...path].tsx b/routes/membres/[id]/portfolio/[...path].tsx deleted file mode 100644 index 4e6a7d6..0000000 --- a/routes/membres/[id]/portfolio/[...path].tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Handlers, RouteConfig } from '$fresh/server.ts' - -import { contentType } from '$std/media_types/mod.ts' -import { parse } from '$std/path/mod.ts' - -const db = [ - 'julien.oculi', -] - -async function getPortfolio( - user: string, - pathname: string, -): Promise { - const url = new URL( - pathname, - `https://git.cohabit.fr/${user}/.portfolio/raw/branch/main/`, - ) - - const { ext } = parse(pathname) - - try { - const response = await fetch(url) - if (response.ok) { - return new Response(response.body, { - headers: { - 'Content-Type': contentType(ext) ?? 'text/plain; charset=utf-8', - }, - }) - } - throw new Error(response.statusText) - } catch (error) { - return new Response( - 'Portfolio introuvable\n```js\n' + String(error) + '\n```', - ) - } -} - -export const config: RouteConfig = { - skipAppWrapper: true, -} - -export const handler: Handlers = { - GET(req, _ctx) { - const url = new URL(req.url) - const id = Number(url.pathname.split('/')[2]) - const user = db[id] - const query = url.pathname.split('/').slice(4).join('/') - return getPortfolio(user, query === '' ? 'index.html' : query) - }, -}