Skip to content

Commit

Permalink
Render id on the title link to allow browser anchoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kudlajz committed Aug 1, 2024
1 parent 8151424 commit 170ad68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/CoverageCard/CoverageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getCoverageImageUrl } from './getCoverageImageUrl';
interface Props {
className?: string;
coverage: CoverageEntry;
id: string;
layout: 'vertical' | 'horizontal';
newTab: boolean;
renderDate: (date: string) => ReactNode;
Expand All @@ -18,6 +19,7 @@ interface Props {
export function CoverageCard({
className,
coverage,
id,
layout,
newTab,
renderDate,
Expand All @@ -37,7 +39,7 @@ export function CoverageCard({
{imageUrl && withThumbnail && <Thumbnail src={imageUrl} href={href} newTab={newTab} />}

<div className="prezly-slate-coverage-card-component__details">
<Title coverage={coverage} href={href} newTab={newTab} />
<Title coverage={coverage} href={href} id={id} newTab={newTab} />

<Description coverage={coverage} />

Expand Down Expand Up @@ -72,8 +74,13 @@ function Thumbnail(props: { href: string | null; newTab: boolean; src: string })
);
}

function Title(props: { coverage: CoverageEntry; href: string | null; newTab: boolean }) {
const { coverage, href, newTab } = props;
function Title(props: {
coverage: CoverageEntry;
href: string | null;
id: string;
newTab: boolean;
}) {
const { coverage, href, id, newTab } = props;
const title =
coverage.headline ||
coverage.attachment_oembed?.title ||
Expand All @@ -85,6 +92,7 @@ function Title(props: { coverage: CoverageEntry; href: string | null; newTab: bo
<Tag
className="prezly-slate-coverage-card-component__title"
href={href || undefined}
id={id}
target={newTab ? '_blank' : undefined}
>
{title}
Expand Down
1 change: 1 addition & 0 deletions src/elements/Coverage/Coverage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function Coverage({ coverage, node, renderDate }: Props) {
<CoverageCard
className="prezly-slate-coverage"
coverage={coverage}
id={`coverage-${node.uuid}`}
layout={node.layout}
newTab={node.new_tab}
renderDate={renderDate}
Expand Down

0 comments on commit 170ad68

Please sign in to comment.