-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from UW-Macrostrat/vite-v5
Upgrade Vite bundler to v5
- Loading branch information
Showing
4 changed files
with
245 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,7 @@ | ||
import h from "@macrostrat/hyper"; | ||
import { PageContextBuiltInServer } from "vike/types"; | ||
import { ClientOnly } from "~/renderer/client-only"; | ||
import { apiV2Prefix } from "~/settings"; | ||
const MapInterface = () => import("./map-interface"); | ||
|
||
const apiAddress = apiV2Prefix + "/defs/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 data: any = await response.json(); | ||
const map = data?.success?.data?.features[0]; | ||
|
||
return { | ||
pageContext: { | ||
pageProps: { | ||
map, | ||
}, | ||
documentProps: { | ||
// The page's <title> | ||
title: map.properties.name, | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export function Page({ map }) { | ||
return h("div.single-map", h(ClientOnly, { component: MapInterface, map })); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PageContextBuiltInServer } from "vike/types"; | ||
import { apiV2Prefix } from "~/settings"; | ||
|
||
const apiAddress = apiV2Prefix + "/defs/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 data: any = await response.json(); | ||
const map = data?.success?.data?.features[0]; | ||
|
||
return { | ||
pageContext: { | ||
pageProps: { | ||
map, | ||
}, | ||
documentProps: { | ||
// The page's <title> | ||
title: map.properties.name, | ||
}, | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters