diff --git a/src/pages/maps/@id/edit/index.page.ts b/src/pages/maps/@id/edit/index.page.ts index e2f5ab29..07c5898b 100644 --- a/src/pages/maps/@id/edit/index.page.ts +++ b/src/pages/maps/@id/edit/index.page.ts @@ -3,18 +3,24 @@ import { SETTINGS } from "~/settings"; import h from "@macrostrat/hyper"; import { ClientOnly } from "~/renderer/client-only"; -const apiAddress = SETTINGS.apiDomain + "/api/v2/defs/sources"; +const apiAddress = import.meta.env.VITE_MACROSTRAT_INGEST_API + "/sources/"; export async function onBeforeRender(pageContext: PageContextBuiltInServer) { const { id } = pageContext.routeParams; - const params = new URLSearchParams({ - format: "geojson", - source_id: id, - }); - const response = await fetch(apiAddress + "?" + params); + const response = await fetch(apiAddress + id); const data: any = await response.json(); - const map = data?.success?.data?.features[0]; + const map = { + "type": "Feature", + "geometry": { + ...data.geometry + }, + properties: { + ...data + } + } + + console.log(map, apiAddress + id, map.type) return { pageContext: { @@ -24,7 +30,7 @@ export async function onBeforeRender(pageContext: PageContextBuiltInServer) { }, documentProps: { // The page's - title: map.properties.name, + title: data.name, }, }, }; diff --git a/src/pages/maps/index.page.server.ts b/src/pages/maps/index.page.server.ts index 23d74502..a55f29b8 100644 --- a/src/pages/maps/index.page.server.ts +++ b/src/pages/maps/index.page.server.ts @@ -1,13 +1,17 @@ import fetch from "node-fetch"; import { SETTINGS } from "~/settings"; -const apiAddress = SETTINGS.apiDomain + "/api/v2/defs/sources"; +const apiAddress = import.meta.env.VITE_MACROSTRAT_INGEST_API + "/sources"; export async function onBeforeRender(pageContext) { // `.page.server.js` files always run in Node.js; we could use SQL/ORM queries here. - const response = await fetch(apiAddress + "?format=json"); - const res = await response.json(); - let sources = res.success.data; + const url = new URL(apiAddress); + url.searchParams.set("page_size", "9999"); + + + + const response = await fetch(url.toString()); + const sources = await response.json(); sources.sort((a, b) => a.source_id - b.source_id); const pageProps = { sources };