File tree Expand file tree Collapse file tree 2 files changed +45
-4
lines changed
pages/columns/groups/@group Expand file tree Collapse file tree 2 files changed +45
-4
lines changed Original file line number Diff line number Diff line change 1- import { usePageContext } from "vike-react/usePageContext" ;
21import { IndividualPage } from "../../../lex/index" ;
2+ import { useData } from "vike-react/useData" ;
33
44export function Page ( ) {
5- const pageContext = usePageContext ( ) ;
6- const id = parseInt ( pageContext . urlParsed . pathname . split ( "/" ) [ 3 ] ) ;
7- return IndividualPage ( id , "col_group_id" , "groups" ) ;
5+ const { res, fossilRes, colData, taxaData } = useData ( ) ;
6+
7+ return IndividualPage (
8+ res [ 0 ] . col_group_id ,
9+ "groups" ,
10+ res ,
11+ fossilRes ,
12+ colData ,
13+ taxaData
14+ ) ;
815}
Original file line number Diff line number Diff line change 1+ import { apiV2Prefix } from "@macrostrat-web/settings" ;
2+ import { fetchAPIData } from "~/_utils" ;
3+
4+ export async function data ( pageContext ) {
5+ const col_group_id = parseInt ( pageContext . urlParsed . pathname . split ( "/" ) [ 3 ] ) ;
6+
7+ // Await all API calls
8+ const [ res , fossilRes , colData ] = await Promise . all ( [
9+ fetchAPIData ( "/defs/groups" , { col_group_id } ) ,
10+ ( await fetch ( apiV2Prefix + "/fossils?col_group_id=" + col_group_id ) ) . json ( ) ,
11+ (
12+ await fetch (
13+ apiV2Prefix +
14+ "/columns?col_group_id=" +
15+ col_group_id +
16+ "&response=long&format=geojson"
17+ )
18+ ) . json ( ) ,
19+ ] ) ;
20+
21+ const cols = colData . success . data . features
22+ ?. map ( ( feature ) => feature . properties . col_id )
23+ ?. join ( "," ) ;
24+
25+ let taxaData = null ;
26+ if ( cols ) {
27+ const response = await fetch (
28+ `https://paleobiodb.org/data1.2/occs/prevalence.json?limit=5&coll_id=${ cols } `
29+ ) ;
30+ taxaData = await response . json ( ) ;
31+ }
32+
33+ return { res, fossilRes, colData, taxaData } ;
34+ }
You can’t perform that action at this time.
0 commit comments