Skip to content

Commit

Permalink
improvement: use PublicationLink in ClickablePublicationCover
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstadler committed Oct 23, 2024
1 parent 0bc53f7 commit 005153a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/publications/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export default async function PublicationPage(props: PublicationPageProps) {
<LanguageLink language={pub.language} />
</NameValue>
<NameValue name={t("translated_by")}>
<InlineList>
<InlineList separator=" / ">
{translatorInfo.map((t, i) => {
return (
<span key={i}>
<span key={i} className="text-nowrap">
<TranslatorLink translator={t[0]} />
{showIndices ? <sup>{i + 1}</sup> : null}
</span>
Expand Down
8 changes: 4 additions & 4 deletions components/publication-cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ReactNode } from "react";

import type { Publication } from "@/lib/model";

import { AppLink } from "./app-link";
import { PublicationLink } from "./publication-link";

interface PublicationCoverProps {
publication: Publication;
Expand All @@ -29,14 +29,14 @@ export function PublicationCover(props: PublicationCoverProps): ReactNode {

export function ClickablePublicationThumbnail(props: PublicationCoverProps) {
return (
<AppLink
<PublicationLink
className="relative block h-full object-contain hover:outline"
href={`/publication/${props.publication.id}`}
publication={props.publication}
>
<PublicationCover publication={props.publication} />
<span className="sr-only">
{props.publication.title} ({props.publication.year})
</span>
</AppLink>
</PublicationLink>
);
}
8 changes: 7 additions & 1 deletion components/publication-link.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import type { ReactNode } from "react";

import type { Publication } from "@/lib/model";

import { AppLink } from "./app-link";

interface PublicationLinkProps {
publication: Publication;
className?: string;
children?: ReactNode;
}

export function PublicationLink(props: PublicationLinkProps) {
return (
<AppLink href={`/publications/${props.publication.id}`}>{props.publication.title}</AppLink>
<AppLink className={props.className} href={`/publications/${props.publication.id}`}>
{props.children ?? props.publication.title}
</AppLink>
);
}

0 comments on commit 005153a

Please sign in to comment.