search_awesome/routes/dynamic.tsx
2022-12-01 19:40:03 +09:00

31 lines
932 B
TypeScript

import { Head } from "$fresh/runtime.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
import { RepoData, getRepos, searchRepos } from "../api/repo.ts";
import { useState } from "preact/hooks";
import { SearchBar } from "../components/SearchBar.tsx";
import RepoViewer from "../islands/RepoViewer.tsx";
import Search from "../islands/Search.tsx";
export const handler: Handlers = {
GET: (req, ctx) => {
const url = new URL(req.url);
const searchParams = url.searchParams;
const query = searchParams.get("q");
return ctx.render({query})
},
};
export default function Home({ data }: PageProps<{query?: string}>) {
return (
<>
<Head>
<title>Search Github Awesome App</title>
</Head>
<div class="p-4 mx-auto max-w-screen-md">
<h1 class="text-4xl font-bold">Search Github Awesome App</h1>
<Search query={data.query}></Search>
</div>
</>
);
}