diff --git a/app/routes/worlds.$id.tsx b/app/routes/worlds.$id.tsx index 291ba26..b406b73 100644 --- a/app/routes/worlds.$id.tsx +++ b/app/routes/worlds.$id.tsx @@ -1,4 +1,4 @@ -import type { LoaderArgs } from "@remix-run/cloudflare"; +import type { LoaderArgs, V2_MetaFunction } from "@remix-run/cloudflare"; import { json } from "@remix-run/cloudflare"; import { useLoaderData } from "@remix-run/react"; import { @@ -14,7 +14,11 @@ export const loader = async ({ params }: LoaderArgs) => { return json(await worldQuery(params.id as string)); }; -export default function Index() { +export const meta: V2_MetaFunction = ({ data }) => { + return [{ title: `${data.world.name} | PS2.LIVE` }]; +}; + +export default function World() { const { world } = useLoaderData(); return ( diff --git a/app/utils/saerro.ts b/app/utils/saerro.ts index 7407f67..ddbe3c1 100644 --- a/app/utils/saerro.ts +++ b/app/utils/saerro.ts @@ -1,11 +1,12 @@ export const saerroFetch = async (query: string): Promise => { - const response = await fetch("https://saerro.ps2.live/graphql", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ query }), - }); + const response = await fetch( + `https://saerro.ps2.live/graphql?query=${query}`, + { + cf: { + cacheTtl: 60, + }, + } + ); const json: { data: T } = await response.json(); return json.data; }; @@ -52,7 +53,7 @@ export type IndexResponse = { }; export const indexQuery = async (): Promise => { - const query = `query { + const query = `{ health { ingestReachable ingest @@ -128,7 +129,7 @@ export const allClasses = [ ]; export const worldQuery = async (worldID: string): Promise => { - const query = `query { + const query = `{ world(by: {id: ${Number(worldID)}}) { id name @@ -162,8 +163,6 @@ export const worldQuery = async (worldID: string): Promise => { } }`; - console.log(query); - const worldData: WorldResponse = await saerroFetch(query); return worldData;