From 32c1458a9c87e309e3bf4460dea1d31aad002b1f Mon Sep 17 00:00:00 2001 From: monoid Date: Thu, 26 Oct 2023 22:09:44 +0900 Subject: [PATCH] feat: show page description --- routes/pages/[name].tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/routes/pages/[name].tsx b/routes/pages/[name].tsx index 8833130..a8b26a1 100644 --- a/routes/pages/[name].tsx +++ b/routes/pages/[name].tsx @@ -1,14 +1,26 @@ -import { PageProps } from "$fresh/server.ts"; +import { PageProps, Handlers } from "$fresh/server.ts"; import { Head } from "$fresh/runtime.ts"; +import { get_pages_meta, PageDescription } from "../../pages.ts"; import StockList from "../../islands/StockList.tsx"; +export const handler: Handlers = { + async GET(_req, ctx) { + const [pages, _] = await get_pages_meta(); + const name = ctx.params.name; + const page = pages.filter(x=> x.name === name); + if (page.length === 0) { + return await ctx.renderNotFound(); + } + return await ctx.render(page[0]); + }, +}; -export default function Pages(props: PageProps) { +export default function Pages(props: PageProps) { return <> Stock: {props.params.name} -
+
stock graph

{props.params.name}

+

{props.data.description}