Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Commit

Permalink
fix: reformat tables
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Mar 11, 2024
1 parent 3484535 commit 461d1cb
Show file tree
Hide file tree
Showing 280 changed files with 1,624 additions and 582 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ out/
/playwright-report/
/test-results/

# generated metadata
/public/metadata/


## .dockerignore ##

Expand Down
6 changes: 4 additions & 2 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ NEXT_PUBLIC_MATOMO_BASE_URL="https://matomo.acdh.oeaw.ac.at"
# -------------------------------------------------------------------------------------------------
# typesense
# -------------------------------------------------------------------------------------------------
NEXT_PUBLIC_TYPESENSE_PORT=
NEXT_PUBLIC_TYPESENSE_API_KEY=
NEXT_PUBLIC_TYPESENSE_HOST=
NEXT_PUBLIC_TYPESENSE_COLLECTION_ID=
NEXT_PUBLIC_TYPESENSE_PORT=
NEXT_PUBLIC_TYPESENSE_PROTOCOL=
TYPESENSE_ADMIN_API_KEY=
4 changes: 4 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ jobs:
NEXT_PUBLIC_MATOMO_BASE_URL="${{ vars.NEXT_PUBLIC_MATOMO_BASE_URL }}"
NEXT_PUBLIC_MATOMO_ID="${{ vars.NEXT_PUBLIC_MATOMO_ID }}"
NEXT_PUBLIC_REDMINE_ID="${{ vars.SERVICE_ID }}"
NEXT_PUBLIC_TYPESENSE_API_KEY="${{ vars.NEXT_PUBLIC_TYPESENSE_API_KEY }}"
NEXT_PUBLIC_TYPESENSE_HOST="${{ vars.NEXT_PUBLIC_TYPESENSE_HOST }}"
NEXT_PUBLIC_TYPESENSE_PORT="${{ vars.NEXT_PUBLIC_TYPESENSE_PORT }}"
NEXT_PUBLIC_TYPESENSE_PROTOCOL="${{ vars.NEXT_PUBLIC_TYPESENSE_PROTOCOL }}"
cache-from: type=gha
cache-to: type=gha,mode=max

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ jobs:
env:
NEXT_PUBLIC_APP_BASE_URL: "http://localhost:3000"
NEXT_PUBLIC_REDMINE_ID: "${{ vars.SERVICE_ID }}"
NEXT_PUBLIC_TYPESENSE_API_KEY: "${{ vars.NEXT_PUBLIC_TYPESENSE_API_KEY }}"
NEXT_PUBLIC_TYPESENSE_HOST: "${{ vars.NEXT_PUBLIC_TYPESENSE_HOST }}"
NEXT_PUBLIC_TYPESENSE_PORT: "${{ vars.NEXT_PUBLIC_TYPESENSE_PORT }}"
NEXT_PUBLIC_TYPESENSE_PROTOCOL: "${{ vars.NEXT_PUBLIC_TYPESENSE_PROTOCOL }}"

- name: Run e2e tests
run: pnpm run test:e2e
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ out/
/playwright/.cache/
/playwright-report/
/test-results/

# generated metadata
/public/metadata/
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ ARG NEXT_PUBLIC_KEYSTATIC_MODE
ARG NEXT_PUBLIC_MATOMO_BASE_URL
ARG NEXT_PUBLIC_MATOMO_ID
ARG NEXT_PUBLIC_REDMINE_ID
ARG NEXT_PUBLIC_TYPESENSE_API_KEY
ARG NEXT_PUBLIC_TYPESENSE_HOST
ARG NEXT_PUBLIC_TYPESENSE_PORT
ARG NEXT_PUBLIC_TYPESENSE_PROTOCOL

RUN pnpm install --frozen-lockfile --offline

Expand Down
4 changes: 2 additions & 2 deletions app/[locale]/(index)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export default function IndexPage(props: IndexPageProps): ReactNode {

return (
<MainContent className="container grid grid-rows-[auto_1fr] py-4 xs:py-8">
<section className="mx-auto grid w-full max-w-screen-md items-start justify-items-center gap-y-4 px-2 py-8 text-center md:py-12">
<section className="grid w-full items-start justify-items-center gap-y-4 py-8 text-center md:py-12">
<h1 className="text-balance text-3xl font-bold leading-tight tracking-tighter text-neutral-950 md:text-5xl dark:text-neutral-0">
{t("title")}
</h1>
<div className="text-pretty text-md leading-normal text-neutral-500 xs:text-lg xs:leading-snug dark:text-neutral-400">
<div className="text-pretty text-md leading-normal text-neutral-600 xs:text-lg xs:leading-snug dark:text-neutral-400">
{t("lead-in")}
</div>
</section>
Expand Down
68 changes: 34 additions & 34 deletions app/[locale]/curricula/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { assert, isNonNullable } from "@acdh-oeaw/lib";
import { compareDesc } from "date-fns";
import type { Metadata, ResolvingMetadata } from "next";
import { draftMode } from "next/headers";
import { notFound } from "next/navigation";
import {
getFormatter,
Expand All @@ -10,11 +8,12 @@ import {
} from "next-intl/server";
import type { ReactNode } from "react";

import { DraftModeToggle } from "@/components/draft-mode-toggle";
import { MainContent } from "@/components/main-content";
import { ResourcesList } from "@/components/resources-list";
import { PageTitle } from "@/components/ui/page-title";
import type { Locale } from "@/config/i18n.config";
import { processMdx } from "@/lib/content/mdx";
import { getCurriculumContent } from "@/lib/content/mdx";
import { reader } from "@/lib/content/reader";
import { getDublinCoreMetadata } from "@/lib/metadata/get-dublin-core-metadata";
import { getHighwireMetadata } from "@/lib/metadata/get-highwire-metadata";
Expand Down Expand Up @@ -91,7 +90,9 @@ export default function CurriculumPage(props: CurriculumPageProps): ReactNode {
setRequestLocale(locale);

return (
<MainContent className="prose container max-w-screen-md py-4 xs:py-8">
<MainContent className="container py-4 xs:py-8">
<DraftModeToggle />

<CurriculumContent id={id} />
</MainContent>
);
Expand All @@ -108,41 +109,46 @@ async function CurriculumContent(props: CurriculumContentProps): Promise<ReactNo
const t = await getTranslations("CurriculumContent");
const { dateTime, list } = await getFormatter();

const { Content, curriculum } = await getCurriculumContent(id);
const { Content, frontmatter: curriculum } = await getCurriculumContent(id);

const editors = await Promise.all(
curriculum.editors.map((id) => {
return reader().collections.people.read(id);
}),
);

const _resources = await Promise.all(
const resources = await Promise.all(
curriculum.resources.map(async (id) => {
const resource = await reader().collections.resources.read(id);
assert(resource, "Missing resource.");
return { ...resource, id };
}),
);
const resources = _resources.filter(isNonNullable).sort((a, z) => {
return compareDesc(a.publicationDate, z.publicationDate);
});

const tags = await Promise.all(
curriculum.tags.map((id) => {
return reader().collections.tags.read(id);
}),
);

return (
<div>
<div className="prose prose-sm w-full">
<PageTitle>{curriculum.title}</PageTitle>

<div className="border-b">
<dl className="grid leading-normal">
<div className="inline">
<dt className="inline">{t("edited-by")} </dt>
<dd className="inline pl-1">
{list(
editors.filter(isNonNullable).map((editor) => {
return [editor.firstName, editor.lastName].join(" ");
}),
)}
</dd>
</div>
{editors.length > 0 ? (
<div className="inline">
<dt className="inline">{t("edited-by")} </dt>
<dd className="inline pl-1">
{list(
editors.filter(isNonNullable).map((editor) => {
return [editor.firstName, editor.lastName].join(" ");
}),
)}
</dd>
</div>
) : null}
<div className="inline">
<dt className="inline">{t("published-on")} </dt>
<dd className="inline pl-1">
Expand All @@ -151,7 +157,14 @@ async function CurriculumContent(props: CurriculumContentProps): Promise<ReactNo
</div>
<div className="inline">
<dt className="inline">{t("tagged-with")} </dt>
<dd className="inline pl-1">{list(curriculum.tags)}</dd>
<dd className="inline pl-1">
{list(
tags.map((tag) => {
assert(tag, "Missing tag.");
return tag.name;
}),
)}
</dd>
</div>
</dl>
</div>
Expand All @@ -162,16 +175,3 @@ async function CurriculumContent(props: CurriculumContentProps): Promise<ReactNo
</div>
);
}

async function getCurriculumContent(id: string) {
const curriculum = await reader().collections.curricula.read(id);

if (curriculum == null) notFound();

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { default: Content } = draftMode().isEnabled
? await processMdx(await curriculum.content())
: await import(`@/content/curricula/${id}/index.mdx`);

return { Content, curriculum };
}
15 changes: 1 addition & 14 deletions app/[locale]/curricula/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,11 @@ import { createResourceFiltersSearchParamsSchema } from "@/lib/schemas/resource-

interface CurriculaPageProps {
params: {
id: string;
locale: Locale;
};
searchParams: Record<string, Array<string> | string>;
}

export const dynamicParams = false;

export async function generateStaticParams(_props: {
params: Pick<CurriculaPageProps["params"], "locale">;
}): Promise<Array<Pick<CurriculaPageProps["params"], "id">>> {
const ids = await Promise.resolve([]);

return ids.map((id) => {
return { id };
});
}

export async function generateMetadata(
props: CurriculaPageProps,
_parent: ResolvingMetadata,
Expand Down Expand Up @@ -68,7 +55,7 @@ export default function CurriculaPage(props: CurriculaPageProps): ReactNode {

return (
<MainContent className="container grid grid-rows-[auto_1fr] gap-y-8 py-4 xs:py-8 md:py-12">
<div className="mx-auto w-full max-w-screen-md px-2 xs:px-8">
<div className="w-full">
<PageTitle>{t("title")}</PageTitle>
</div>

Expand Down
7 changes: 4 additions & 3 deletions app/[locale]/documentation/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { DraftModeToggle } from "@/components/draft-mode-toggle";
import { MainContent } from "@/components/main-content";
import { PageTitle } from "@/components/ui/page-title";
import type { Locale } from "@/config/i18n.config";
import { getDocumentationContent } from "@/lib/content/mdx";
import { reader } from "@/lib/content/reader";
import type { DocumentationPage } from "@/lib/content/types";

interface DocumentationPageProps {
params: {
Expand Down Expand Up @@ -73,11 +75,10 @@ async function DocumentationPageContent(props: DocumentationPageContentProps): P
const document = await reader().collections.documentation.read(id);
if (document == null) notFound();

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { default: Content } = await import(`@/content/documentation/${id}.mdx`);
const { Content } = await getDocumentationContent(id);

return (
<div className="prose mx-auto w-full max-w-screen-md">
<div className="prose prose-sm w-full">
<PageTitle>{document.title}</PageTitle>

<Content />
Expand Down
4 changes: 2 additions & 2 deletions app/[locale]/imprint/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function ImprintPage(props: ImprintPageProps): ReactNode {
const t = useTranslations("ImprintPage");

return (
<MainContent className="prose container py-4 xs:py-8">
<MainContent className="container py-4 xs:py-8">
<ImprintPageContent locale={locale} title={t("title")} />
</MainContent>
);
Expand All @@ -59,7 +59,7 @@ async function ImprintPageContent(props: ImprintPageContentProps): Promise<React
const html = await getImprintHtml(locale);

return (
<div className="prose prose-sm mx-auto w-full max-w-screen-md px-2 xs:px-8">
<div className="prose prose-sm w-full">
<PageTitle>{title}</PageTitle>

<div dangerouslySetInnerHTML={{ __html: html }} />
Expand Down
45 changes: 23 additions & 22 deletions app/[locale]/resources/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { assert, isNonNullable } from "@acdh-oeaw/lib";
import { evaluate } from "@mdx-js/mdx";
import type { Metadata, ResolvingMetadata } from "next";
import { draftMode } from "next/headers";
import { notFound } from "next/navigation";
import {
getFormatter,
getTranslations,
unstable_setRequestLocale as setRequestLocale,
} from "next-intl/server";
import type { ReactNode } from "react";
import * as runtime from "react/jsx-runtime";

import { DraftModeToggle } from "@/components/draft-mode-toggle";
import { MainContent } from "@/components/main-content";
import { PageTitle } from "@/components/ui/page-title";
import type { Locale } from "@/config/i18n.config";
import { getResourceContent } from "@/lib/content/mdx";
import { reader } from "@/lib/content/reader";
import { getDublinCoreMetadata } from "@/lib/metadata/get-dublin-core-metadata";
import { getHighwireMetadata } from "@/lib/metadata/get-highwire-metadata";
Expand All @@ -30,7 +29,7 @@ export const dynamicParams = false;
export async function generateStaticParams(_props: {
params: Pick<ResourcePageProps["params"], "locale">;
}): Promise<Array<Pick<ResourcePageProps["params"], "id">>> {
const ids = await reader().collections.resources.list()
const ids = await reader().collections.resources.list();

return ids.map((id) => {
return { id };
Expand All @@ -46,7 +45,7 @@ export async function generateMetadata(
const { id } = params;

const resource = await reader().collections.resources.read(id);
if (resource == null) notFound()
if (resource == null) notFound();

const layoutMetadata = await parent;
const siteTitle = layoutMetadata.title?.absolute;
Expand Down Expand Up @@ -90,7 +89,9 @@ export default function ResourcePage(props: ResourcePageProps): ReactNode {
setRequestLocale(locale);

return (
<MainContent className="prose container max-w-screen-md py-4 xs:py-8">
<MainContent className="container py-4 xs:py-8">
<DraftModeToggle />

<ResourceContent id={id} />
</MainContent>
);
Expand All @@ -107,16 +108,22 @@ async function ResourceContent(props: ResourceContentProps): Promise<ReactNode>
const t = await getTranslations("ResourceContent");
const { dateTime, list } = await getFormatter();

const { Content, resource } = await getResourceContent(id);
const { Content, frontmatter: resource } = await getResourceContent(id);

const authors = await Promise.all(
resource.authors.map((id) => {
return reader().collections.people.read(id);
}),
);

const tags = await Promise.all(
resource.tags.map((id) => {
return reader().collections.tags.read(id);
}),
);

return (
<div>
<div className="prose prose-sm w-full">
<PageTitle>{resource.title}</PageTitle>

<div className="border-b">
Expand All @@ -139,7 +146,14 @@ async function ResourceContent(props: ResourceContentProps): Promise<ReactNode>
</div>
<div className="inline">
<dt className="inline">{t("tagged-with")} </dt>
<dd className="inline pl-1">{list(resource.tags)}</dd>
<dd className="inline pl-1">
{list(
tags.map((tag) => {
assert(tag, "Missing tag.");
return tag.name;
}),
)}
</dd>
</div>
</dl>
</div>
Expand All @@ -148,16 +162,3 @@ async function ResourceContent(props: ResourceContentProps): Promise<ReactNode>
</div>
);
}

async function getResourceContent(id: string) {
const resource = await reader().collections.resources.read(id);

if (resource == null) notFound();

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { default: Content } = draftMode().isEnabled
? await evaluate(await resource.content(), { development: false, ...runtime })
: await import(`@/content/resources/${id}/index.mdx`);

return { Content, resource };
}
Loading

0 comments on commit 461d1cb

Please sign in to comment.