-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port /pathogens to App Router [#1066]
- Loading branch information
Showing
1 changed file
with
69 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,77 @@ | ||
import React from "react"; | ||
import { | ||
SmallSpacer, | ||
HugeSpacer, | ||
FlexCenter, | ||
} from "../layouts/generalComponents"; | ||
import ListResources from "../components/ListResources/index"; | ||
import * as splashStyles from "../components/splash/styles"; | ||
import GenericPage from "../layouts/generic-page"; | ||
import {coreQuickLinks, coreGroupDisplayNames, coreTiles} from "../../content/resource-listing.yaml"; | ||
|
||
const title = "Nextstrain-maintained pathogen analyses"; | ||
const abstract = ( | ||
<> | ||
These data represent analyses and situation-reports produced by the <a href="/team">core Nextstrain team</a>. | ||
Explore analyses produced by others on the <a href="/groups">Groups</a> and <a href="/community">Community</a> pages. | ||
<br/><br/> | ||
We aim to provide a continually-updated view of publicly available data to show pathogen evolution and epidemic spread. | ||
The pipeline used to generate each dataset is available on <a href="https://github.com/nextstrain/">our GitHub page</a> or by loading a dataset and | ||
clicking the “built with” link at the top of the page. | ||
</> | ||
); | ||
|
||
const resourceListingCallback = async () => { | ||
const sourceId = "core" | ||
|
||
import FlexCenter from "../../components/flex-center"; | ||
import { FocusParagraphCentered } from "../../components/focus-paragraph"; | ||
import ListResources from "../../components/list-resources"; | ||
import { ResourceListingInfo } from "../../components/list-resources/types"; | ||
import { SmallSpacer, HugeSpacer } from "../../components/spacers"; | ||
import * as coreResources from "../../content/resource-listing.yaml"; | ||
|
||
/** | ||
* React Server Component that generates and presents a list of | ||
* pathogen resources. | ||
*/ | ||
export default function Pathogens(): React.ReactElement { | ||
return ( | ||
<> | ||
<HugeSpacer /> | ||
<HugeSpacer /> | ||
|
||
<h1>Nextstrain-maintained pathogen analyses</h1> | ||
|
||
<SmallSpacer /> | ||
|
||
<FlexCenter> | ||
<FocusParagraphCentered> | ||
These data represent analyses and situation-reports produced by the{" "} | ||
<a href="/team">core Nextstrain team</a>. Explore analyses produced by | ||
others on the <a href="/groups">Groups</a> and{" "} | ||
<a href="/community">Community</a> pages. | ||
<br /> | ||
<br /> | ||
We aim to provide a continually-updated view of publicly available | ||
data to show pathogen evolution and epidemic spread. The pipeline used | ||
to generate each dataset is available on{" "} | ||
<a href="https://github.com/nextstrain/">our GitHub page</a> or by | ||
loading a dataset and clicking the “built with” link at | ||
the top of the page. | ||
</FocusParagraphCentered> | ||
</FlexCenter> | ||
|
||
<HugeSpacer /> | ||
|
||
<ListResources | ||
defaultGroupLinks | ||
groupDisplayNames={coreResources["coreGroupDisplayNames"]} | ||
quickLinks={coreResources["coreQuickLinks"]} | ||
resourceType="dataset" | ||
tileData={coreResources["coreTiles"]} | ||
versioned | ||
/> | ||
|
||
<HugeSpacer /> | ||
</> | ||
); | ||
} | ||
|
||
/** | ||
* A callback function used by the <ListResources> component (which | ||
* see) to get the resources to display on the `/pathogens` page. | ||
* | ||
* @returns A Promise that resolves to a ResourceListingInfo | ||
*/ | ||
export async function pathogenResourceListingCallback(): Promise<ResourceListingInfo> { | ||
const sourceId = "core"; | ||
const sourceUrl = `list-resources/${sourceId}`; | ||
|
||
const response = await fetch(sourceUrl, {headers: {accept: "application/json"}}); | ||
const response = await fetch(sourceUrl, { | ||
headers: { accept: "application/json" }, | ||
}); | ||
if (response.status !== 200) { | ||
throw new Error(`fetching data from "${sourceUrl}" returned status code ${response.status}`); | ||
throw new Error( | ||
`fetching data from "${sourceUrl}" returned status code ${response.status}`, | ||
); | ||
} | ||
|
||
return (await response.json()).dataset[sourceId]; | ||
}; | ||
|
||
class Index extends React.Component { | ||
render() { | ||
return ( | ||
<GenericPage> | ||
<splashStyles.H1>{title}</splashStyles.H1> | ||
<SmallSpacer /> | ||
|
||
<FlexCenter> | ||
<splashStyles.CenteredFocusParagraph> | ||
{abstract} | ||
</splashStyles.CenteredFocusParagraph> | ||
</FlexCenter> | ||
|
||
<HugeSpacer/> | ||
|
||
<ListResources resourceType="dataset" | ||
tileData={coreTiles} | ||
quickLinks={coreQuickLinks} defaultGroupLinks | ||
groupDisplayNames={coreGroupDisplayNames} | ||
resourceListingCallback={resourceListingCallback}/> | ||
|
||
<HugeSpacer/> | ||
</GenericPage> | ||
); | ||
} | ||
} | ||
|
||
export default Index; |