Skip to content
Merged
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
135 changes: 0 additions & 135 deletions static-site/app/community/[[...community]]/router.tsx

This file was deleted.

26 changes: 26 additions & 0 deletions static-site/app/community/[user]/[repo]/[...path]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import CommunityRepoPage from "../../../repo-page";

/**
* Renders an error page for non-existent resource paths.
*
* This should only be reached if the server's router (src/routing) does not
* find an existing resource at the path. Falls back to showing the repo page
* with an error banner.
*/
export default function Page({
params,
}: {
params: {
user: string;
repo: string;
path: string[];
};
}): React.ReactElement {
return (
<CommunityRepoPage
user={params.user}
repo={params.repo}
extra={params.path.join("/")}
/>
);
}
20 changes: 20 additions & 0 deletions static-site/app/community/[user]/[repo]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import CommunityRepoPage from "../../repo-page";

/**
* Renders the community repo page.
*/
export default function Page({
params,
}: {
params: {
user: string;
repo: string;
};
}): React.ReactElement {
return (
<CommunityRepoPage
user={params.user}
repo={params.repo}
/>
);
}
14 changes: 14 additions & 0 deletions static-site/app/community/[user]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MissingRepoErrorPage } from "../error-page";

/**
* Renders an error page for incomplete user-only paths.
*/
export default function Page({
params,
}: {
params: {
user: string;
};
}): React.ReactElement {
return <MissingRepoErrorPage user={params.user} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import React from "react";

import DatasetSelect from "../../../components/dataset-select";
import DatasetSelect from "../../components/dataset-select";
import {
DatasetSelectColumnsType,
DatasetType,
} from "../../../components/dataset-select/types";
import FlexCenter from "../../../components/flex-center";
import { FocusParagraphCentered } from "../../../components/focus-paragraph";
import { SmallSpacer, HugeSpacer } from "../../../components/spacers";
import communityDatasetsYaml from "../../../content/community-datasets.yaml";
} from "../../components/dataset-select/types";
import FlexCenter from "../../components/flex-center";
import { FocusParagraphCentered } from "../../components/focus-paragraph";
import { SmallSpacer, HugeSpacer } from "../../components/spacers";
import communityDatasetsYaml from "../../content/community-datasets.yaml";
import { title } from "./constants";

/** Column definitions for <DatasetSelect> */
Expand Down
27 changes: 27 additions & 0 deletions static-site/app/community/error-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use client";

import React from "react";

import ErrorMessage from "../../components/error-message";
import CommunityPageContent from "./content";
import { usePathname } from "next/navigation";

/**
* Renders an error page for incomplete user-only paths.
*/
export function MissingRepoErrorPage({
user,
}: {
user: string;
}): React.ReactElement {
const errorPath = "nextstrain.org" + usePathname();
return (
<>
<ErrorMessage
title={`The path "${errorPath}" is not valid. If you are looking for resources under "${user}", add a repo to the path: "${errorPath}/{repo}"`}
contents={<p>Here is the community page instead.</p>}
/>
<CommunityPageContent />
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import CommunityRepoPage from "../../../../repo-page";

/**
* Renders an error page for non-existent resource paths.
*
* This should only be reached if the server's router (src/routing) does not
* find an existing resource at the path. Falls back to showing the repo page
* with an error banner.
*/
export default function Page({
params,
}: {
params: {
user: string;
repo: string;
path: string[];
};
}): React.ReactElement {
return (
<CommunityRepoPage
user={params.user}
repo={params.repo}
extra={params.path.join("/")}
isNarrative={true}
/>
);
}
20 changes: 20 additions & 0 deletions static-site/app/community/narratives/[user]/[repo]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import CommunityRepoPage from "../../../repo-page";

/**
* Renders the community repo page.
*/
export default function Page({
params,
}: {
params: {
user: string;
repo: string;
};
}): React.ReactElement {
return (
<CommunityRepoPage
user={params.user}
repo={params.repo}
/>
);
}
14 changes: 14 additions & 0 deletions static-site/app/community/narratives/[user]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { MissingRepoErrorPage } from "../../error-page";

/**
* Renders an error page for incomplete user-only paths.
*/
export default function Page({
params,
}: {
params: {
user: string;
};
}): React.ReactElement {
return <MissingRepoErrorPage user={params.user} />;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import type { Metadata } from "next";

import CommuityPageRouter from "./router";
import CommunityPageContent from "./content";
import { title } from "./constants";

export const metadata: Metadata = {
Expand All @@ -16,11 +16,7 @@ export const metadata: Metadata = {
* Metadata API (which we want to use so we have functional OpenGraph
* tags, etc.), so this component exists to wrap the router Client
* Component and inject the page title from the metadata into it.
*
* See <CommunityPageRouter> for additional information about how URLs
* that look like `/community/plus/other/stuff` are routed, how errors
* are handled, etc.
*/
export default function CommunityPage(): React.ReactElement {
return <CommuityPageRouter />;
return <CommunityPageContent />;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"use client";

import React, { useEffect, useState } from "react";

import DatasetSelect from "../../../components/dataset-select";
import { DatasetType } from "../../../components/dataset-select/types";
import ErrorMessage from "../../../components/error-message";
import DatasetSelect from "../../components/dataset-select";
import { DatasetType } from "../../components/dataset-select/types";
import ErrorMessage from "../../components/error-message";
import SourceInfoHeading, {
SourceInfo,
} from "../../../components/source-info-heading";
import { HugeSpacer } from "../../../components/spacers";
import fetchAndParseJSON from "../../../util/fetch-and-parse-json";
} from "../../components/source-info-heading";
import { HugeSpacer } from "../../components/spacers";
import fetchAndParseJSON from "../../util/fetch-and-parse-json";

/** Data structure for `/charon/getAvailable` response */
interface AvailableData {
Expand All @@ -27,7 +29,7 @@ interface CommunityResource {
}

/**
* A React Server Component for displaying a page for a community
* A React Client Component for displaying a page for a community
* repo, with metadata about the repo and user, and listing of
* available datasets and narratives in that repo.
*/
Expand All @@ -42,11 +44,11 @@ export default function CommunityRepoPage({
/** Github repo name */
repo: string;
/** Any extra elements in the requested URL past the user and repo */
extra: string;
extra?: string;
/** Was the request for a narrative? (i.e., did `/narratives/`
* appear in the URL?)
*/
isNarrative: boolean;
isNarrative?: boolean;
}): React.ReactElement {
// these flags control what's displayed: the repo content and/or an error banner
const [showContent, setShowContent] = useState<boolean>(false);
Expand Down