Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/errata and contributors #31

Merged
merged 3 commits into from
Mar 18, 2024
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
19 changes: 14 additions & 5 deletions src/components/GeneralGuidance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ const GeneralGuidance: React.FC<Props> = props => {
{t("linkMextText")}
<FiExternalLink className="ml-1 inline-block" />
</Link>
<Link target="_blank" className="link-hover link-info link" href={t("pdfLink")}>
<MdDownload className="mr-1 inline-block" />
{t("pdfLinkText")}
<MdOutlinePictureAsPdf className="ml-1 inline-block" />
</Link>
<span className="flex flex-row gap-3">
<Link target="_blank" className="link-hover link-info link" href={t("pdfLink")}>
<MdDownload className="mr-1 inline-block" />
{t("pdfLinkText")}
<MdOutlinePictureAsPdf className="ml-1 inline-block" />
</Link>
<span>
(
<Link className="link-hover link-info link" href="/errata">
{t("errata")}
</Link>
)
</span>
</span>
<Link className="link-hover link-info link" href="/movies">
{t("movies")}
</Link>
Expand Down
72 changes: 72 additions & 0 deletions src/pages/errata/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import type { NextPage, GetStaticProps } from "next";
import Head from "next/head";
import { BackButton } from "@components/buttons/BackButton";
import { Locale, useTranslation } from "@services/i18n/i18n";

type ErrataInfo = {
position: string;
error: string;
correct: string;
comment: string;
date: string;
};
type PageProps = {
data: ErrataInfo[];
};

export const getStaticProps: GetStaticProps<PageProps> = async ({ locale }) => {
locale = locale as Locale;
const data = locale === "ja" ? (await import("json_in_repo/errata/ja.json")).default : [];
return {
props: { data },
};
};

const HeaderBar = () => {
return (
<div className="bg-base-100/80 sticky top-0 flex w-full items-center backdrop-blur-sm">
<div className="ml-2">
<BackButton />
</div>
</div>
);
};

const ErrataAPage: NextPage<PageProps> = ({ data }: PageProps) => {
const { t } = useTranslation("@pages/errata");

return (
<>
<Head>
<title>{t("title")}</title>
</Head>
<HeaderBar />
<h1 className="text-base-content mt-4 text-center text-3xl">{t("h1")}</h1>
<div className="m-4 pb-24">
{data.map(({ position, error, correct, comment, date }, i) => {
return (
<section key={error} className="mx-auto mb-16 flex w-fit max-w-3xl flex-col gap-2 pl-2">
<h3 className="text-base-content my-4 text-lg">{position}</h3>
<div>
<p className="text-base-content">
<span className="text-accent">{t("errorHeader")}</span> {error}
</p>
<p className="text-base-content">
<span className="text-accent">{t("correctHeader")}</span> {correct}
</p>
</div>
{comment && (
<p className="text-base-content text-sm">
<span className="">{t("commentHeader")}</span> {comment}
</p>
)}
<p className="text-base-content/40 justify-end text-right text-xs">{date}</p>
</section>
);
})}
</div>
</>
);
};

export default ErrataAPage;
55 changes: 52 additions & 3 deletions src/pages/movies/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import { Locale, useTranslation } from "@services/i18n/i18n";

type PageProps = {
data: DataList;
constributors: ContributorInfo[];
};

type ContributorInfo = {
team: string;
category: string;
name: string;
affiliation: string;
};

type FileInfo = {
Expand Down Expand Up @@ -135,8 +143,12 @@ export const loadMovieData = async (locale: Locale): Promise<DataList> => {

export const getStaticProps: GetStaticProps<PageProps> = async ({ locale }) => {
const data = await loadMovieData(locale as Locale);
const constributors =
locale === "ja"
? (await import("json_in_repo/contributors/ja.json")).default
: (await import("json_in_repo/contributors/en.json")).default;
return {
props: { data },
props: { data, constributors },
};
};

Expand Down Expand Up @@ -358,7 +370,29 @@ const Layout = ({ toc, main }: LayoutProps) => {
);
};

const MoviesPage: NextPage<PageProps> = ({ data }: { data: DataList }) => {
const ContributorsList = ({ constributors }: { constributors: ContributorInfo[] }) => {
const { t } = useTranslation("@pages/movies");
return (
<div className="p-8">
<h2 className="text-base-content mt-10 text-2xl" id="contributors">
{t("contributors")}
</h2>
<ul className="flex flex-col gap-3">
{constributors.map(({ team, category, name, affiliation }, i) => {
return (
<li key={i}>
<h3 className="text-base-content mt-10 text-xl">{name}</h3>
<p className="text-base-content">{affiliation}</p>
<p className="text-base-content">{category}</p>
</li>
);
})}
</ul>
</div>
);
};

const MoviesPage: NextPage<PageProps> = ({ data, constributors }) => {
const { t } = useTranslation("@pages/movies");
return (
<div className="h-dvh">
Expand All @@ -367,7 +401,22 @@ const MoviesPage: NextPage<PageProps> = ({ data }: { data: DataList }) => {
</Head>
<HeaderBar />
<div className="h-full">
<Layout toc={<MovieToc data={data} />} main={<WholeMovieCardList data={data} />} />
<Layout
toc={
<div className="flex flex-col gap-5">
<MovieToc data={data} />
<Link href="/movies#contributors" className="link-info block">
{t("contributors")}
</Link>
</div>
}
main={
<div>
<WholeMovieCardList data={data} />
<ContributorsList constributors={constributors} />
</div>
}
/>
</div>
</div>
);
Expand Down
10 changes: 5 additions & 5 deletions src/pages/qanda.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const getStaticProps: GetStaticProps<PageProps> = async ({ locale }) => {

const HeaderBar = () => {
return (
<div className="sticky top-0 flex w-full items-center bg-base-100/80 backdrop-blur-sm">
<div className="bg-base-100/80 sticky top-0 flex w-full items-center backdrop-blur-sm">
<div className="ml-2">
<BackButton />
</div>
Expand All @@ -39,13 +39,13 @@ const QandAPage: NextPage<PageProps> = ({ data }: PageProps) => {
<HeaderBar />
<div className="m-4 pb-24">
{data.map(({ question, answer }, i) => {
const index = i+1
const index = i + 1;
return (
<section key={question} className="mx-auto mb-16 max-w-3xl">
<h3 className="my-4 text-lg text-base-content">
<span className="font-bold text-accent">Q{index}.</span> {question}
<h3 className="text-base-content my-4 text-lg">
<span className="text-accent font-bold">Q{index}.</span> {question}
</h3>
<p className="ml-2 text-base-content">
<p className="text-base-content ml-2">
<span className="text-accent">A{index}.</span> {answer}
</p>
</section>
Expand Down
12 changes: 12 additions & 0 deletions src/services/i18n/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const text = {
notFound: { ja: "は見つかりませんでした。", en: " was not found." },
notFoundToBack: { ja: "動画一覧ページへ戻る", en: "Back to movies list" },
fileExists: { ja: "関連ファイルあり", en: "Related files exist" },
contributors: { ja: "動画制作協力者一覧 (敬称略)", en: "Movie contributors" },
},
"@pages/errata": {
title: { ja: "誤植・誤り一覧 | コアカリナビ", en: "Errata | Core Curriculum Navigator" },
h1: { ja: "誤植・誤り一覧", en: "Errata" },
errorHeader: { ja: "誤り", en: "Error" },
correctHeader: { ja: "訂正", en: "Correction" },
commentHeader: { ja: "注: ", en: "Note: " },
},
"@pages/404": {
title: {
Expand Down Expand Up @@ -306,6 +314,10 @@ const text = {
// eslint-disable-next-line max-len
en: `This page contains the official English translation of the original Japanese revision, produced by the Model Core Curriculum Expert Research Committee of the Japan Society for Medical Education, as part of a project commissioned by the Ministry of Education, Culture, Sports, Science and Technology (MEXT).`,
},
errata: {
ja: "誤植・誤り一覧",
en: "Errata",
},
linkMextText: {
ja: "文部科学省モデル・コア・カリキュラム公表ページ",
en: "MEXT Model Core Curriculum page (Japanese page)",
Expand Down
Loading