Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions static-site/app/ncov/[[...ncov]]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";

import { ErrorBanner } from "../../../components/error-banner";

import SarsCov2PageContent from "../../sars-cov-2/[[...sars-cov-2]]/content";

import ErrorBanner from "./error-banner";
import { metadata } from "./page";

/**
Expand All @@ -11,9 +12,20 @@ import { metadata } from "./page";
* dataset doesn't actually exist.
*/
export default function FourOhFour(): React.ReactElement {
const contents = (
<p>
{`Here is the SARS-CoV-2 page, where we have listed featured datasets,
narratives, and resources related to SARS-CoV-2. Note that some SARS-CoV-2
datasets may not be listed here. For a more comprehensive list of
Nextstrain-maintained (including SARS-CoV-2) datasets,
check out `}
<a href="/pathogens">nextstrain.org/pathogens</a>.
</p>
);

return (
<>
<ErrorBanner />
<ErrorBanner stub="ncov" contents={contents} />
<SarsCov2PageContent metadata={metadata} />
</>
);
Expand Down
5 changes: 3 additions & 2 deletions static-site/app/ncov/[[...ncov]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { Metadata } from "next";

import { ValidateUrl } from "../../../components/error-banner";

import SarsCov2PageContent from "../../sars-cov-2/[[...sars-cov-2]]/content";
import ValidateNcovUrl from "./validateNcovUrl";

const title = "Nextstrain SARS-CoV-2 resources";

Expand All @@ -21,7 +22,7 @@ export const metadata: Metadata = {
export default function SarsCov2Page(): React.ReactElement {
return (
<>
<ValidateNcovUrl />
<ValidateUrl stub="ncov" />
<SarsCov2PageContent metadata={metadata} />
</>
);
Expand Down
23 changes: 0 additions & 23 deletions static-site/app/ncov/[[...ncov]]/validateNcovUrl.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { ResourceListingInfo } from "../../components/list-resources/types";
import { ResourceListingInfo } from "../../../components/list-resources/types";

/**
* A callback function used by the <ListResources> component (which
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
import React from "react";
import { Metadata } from "next";

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";
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";

import { pathogenResourceListingCallback } from "./callback";

const title = "Nextstrain-maintained pathogen analyses";

export const metadata: Metadata = {
title,
};

/**
* React Server Component that generates and presents a list of
* pathogen resources.
* React Server Component that generates the content of the /pathogens page
*
* This is abstracted out into a distinct component so that it can
* also be used in the "./not-found.tsx" component, to render the
* /staging page content beneath an error banner, when a bad URL is
* requested.
*/
export default function Pathogens(): React.ReactElement {
export default function PathogensPageContent({
metadata,
}: {
/**
* A Metadata object, that is assumed to have a `title` key with a
* string value
*/
metadata: Metadata;
}): React.ReactElement {
// the cast is not ideal, but it _is_ going to be a string...
const title = metadata.title as string; // eslint-disable-line @typescript-eslint/consistent-type-assertions

return (
<>
<HugeSpacer />
Expand Down
20 changes: 20 additions & 0 deletions static-site/app/pathogens/[[...pathogens]]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";

import { ErrorBanner } from "../../../components/error-banner";

import PathogensPageContent from "./content";
import { metadata } from "./page";

/**
* A React Server component that renders the usual `/staging` page
* content, with an error banner up-top explaining that the requested
* dataset doesn't actuall exist.
*/
export default function FourOhFour(): React.ReactElement {
return (
<>
<ErrorBanner stub="pathogens" />
<PathogensPageContent metadata={metadata} />
</>
);
}
27 changes: 27 additions & 0 deletions static-site/app/pathogens/[[...pathogens]]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import { Metadata } from "next";

import { ValidateUrl } from "../../../components/error-banner";

import PathogensPageContent from "./content";

const title = "Nextstrain-maintained pathogen analyses";

export const metadata: Metadata = {
title,
};

/**
* React Server Component for `/pathogens`
*
* See note in `static-site/app/staging/[[...staging]]/page.tsx`
* to understand how this works
*/
export default function Pathogens(): React.ReactElement {
return (
<>
<ValidateUrl stub="pathogens" />
<PathogensPageContent metadata={metadata} />
</>
);
}
16 changes: 14 additions & 2 deletions static-site/app/sars-cov-2/[[...sars-cov-2]]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";

import { ErrorBanner } from "../../../components/error-banner";

import SarsCov2PageContent from "./content";
import ErrorBanner from "./error-banner";
import { metadata } from "./page";

/**
Expand All @@ -10,9 +11,20 @@ import { metadata } from "./page";
* dataset doesn't actually exist.
*/
export default function FourOhFour(): React.ReactElement {
const contents = (
<p>
{`Here is the SARS-CoV-2 page, where we have listed featured datasets,
narratives, and resources related to SARS-CoV-2. Note that some SARS-CoV-2
datasets may not be listed here. For a more comprehensive list of
Nextstrain-maintained (including SARS-CoV-2) datasets,
check out `}
<a href="/pathogens">nextstrain.org/pathogens</a>.
</p>
);

return (
<>
<ErrorBanner />
<ErrorBanner stub="sars-cov-2" contents={contents} />
<SarsCov2PageContent metadata={metadata} />
</>
);
Expand Down
5 changes: 3 additions & 2 deletions static-site/app/sars-cov-2/[[...sars-cov-2]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { Metadata } from "next";

import { ValidateUrl } from "../../../components/error-banner";

import SarsCov2PageContent from "./content";
import ValidateSarsUrl from "./validateSarsUrl";

const title = "Nextstrain SARS-CoV-2 resources";

Expand All @@ -21,7 +22,7 @@ export const metadata: Metadata = {
export default function SarsCov2Page(): React.ReactElement {
return (
<>
<ValidateSarsUrl />
<ValidateUrl stub="sars-cov-2" />
<SarsCov2PageContent metadata={metadata} />
</>
);
Expand Down
23 changes: 0 additions & 23 deletions static-site/app/sars-cov-2/[[...sars-cov-2]]/validateSarsUrl.tsx

This file was deleted.

5 changes: 3 additions & 2 deletions static-site/app/staging/[[...staging]]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";

import { ErrorBanner } from "../../../components/error-banner";

import StagingPageContent from "./content";
import ErrorBanner from "./error-banner";
import { metadata } from "./page";

/**
Expand All @@ -12,7 +13,7 @@ import { metadata } from "./page";
export default function FourOhFour(): React.ReactElement {
return (
<>
<ErrorBanner />
<ErrorBanner stub="staging" />
<StagingPageContent metadata={metadata} />
</>
);
Expand Down
11 changes: 6 additions & 5 deletions static-site/app/staging/[[...staging]]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from "react";
import { Metadata } from "next";

import { ValidateUrl } from "../../../components/error-banner";

import StagingPageContent from "./content";
import ValidateStagingUrl from "./validateStagingUrl";

const title = "Staging Data";

Expand Down Expand Up @@ -40,15 +41,15 @@ export const metadata: Metadata = {
* and this page never sees them.
*
* Requests of type #2 and type #3 _are_ handled by this page. It uses
* the `<ValidateStagingUrl>` component to detect whether the
* the `<ValidateUrl>` component to detect whether the
* requested URL was the plain `/staging` or whether there are
* additional path components beyond that (again, `/staging/foo` in
* our example). If there _are_ additional path elements,
* `<ValidateStagingUrl>` detects that and calls Next.js's
* `<ValidateUrl>` detects that and calls Next.js's
* `notFound()` method, which results in the `./not-found.tsx` page
* being rendered and returned. If there are not additional path
* elements (i.e., if the request was for `/staging`),
* `<ValidateStagingUrl>` returns nothing, and the
* `<ValidateUrl>` returns nothing, and the
* `<StagingPageContent>` component delivers the desired resource
* listing.
*
Expand All @@ -61,7 +62,7 @@ export const metadata: Metadata = {
export default function StagingPage(): React.ReactElement {
return (
<>
<ValidateStagingUrl />
<ValidateUrl stub="staging" />
<StagingPageContent metadata={metadata} />
</>
);
Expand Down
23 changes: 0 additions & 23 deletions static-site/app/staging/[[...staging]]/validateStagingUrl.tsx

This file was deleted.

Loading