Skip to content

Commit

Permalink
Port /pathogens to App Router [#1066]
Browse files Browse the repository at this point in the history
  • Loading branch information
genehack committed Mar 3, 2025
1 parent 61a2146 commit e2a9855
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 61 deletions.
17 changes: 17 additions & 0 deletions static-site/app/pathogens/callback.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ResourceListingInfo } from "../../components/list-resources/types";

export async function resourceListingCallback(): Promise<ResourceListingInfo> {
const sourceId = "core";
const sourceUrl = `list-resources/${sourceId}`;

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}`,
);
}

return (await response.json()).dataset[sourceId];
}
109 changes: 48 additions & 61 deletions static-site/app/pathogens/page.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,50 @@
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 &ldquo;built with&rdquo; link at the top of the page.
</>
);

const resourceListingCallback = async () => {
const sourceId = "core"
const sourceUrl = `list-resources/${sourceId}`;

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}`);
}

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;
import FlexCenter from "../../components/flex-center";
import { FocusParagraphCentered } from "../../components/focus-paragraph";
import ListResources from "../../components/list-resources";
import { SmallSpacer, HugeSpacer } from "../../components/spacers";
import * as coreResources from "../../content/resource-listing.yaml";

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 &ldquo;built with&rdquo; 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 />
</>
);
}

0 comments on commit e2a9855

Please sign in to comment.