Skip to content

Commit

Permalink
feat: adds meta description to departure;
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Apr 19, 2024
1 parent 4d25e1c commit 7aabde9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/components/open-graph/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ export function OpenGraphImage({ image }: OpenGraphImageProps) {
);
}

export type OpenGraphDescriptionProps = {
description: string;
};
export function OpenGraphDescription({
description,
}: OpenGraphDescriptionProps) {
return (
<Head>
<meta name="description" content={description} />
<meta property="og:description" content={description} />
</Head>
);
}

export type OpenGraphBaseProps = {
title: string;
};
Expand Down
11 changes: 10 additions & 1 deletion src/page-modules/departures/stop-place/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { DepartureTime } from '@atb/components/departure-time';
import { ColorIcon, MonoIcon } from '@atb/components/icon';
import LineChip from '@atb/components/line-chip';
import { MapWithHeader } from '@atb/components/map';
import { OpenGraphImage } from '@atb/components/open-graph';
import {
OpenGraphDescription,
OpenGraphImage,
} from '@atb/components/open-graph';
import ScreenReaderOnly from '@atb/components/screen-reader-only';
import { Typo } from '@atb/components/typography';
import {
Expand Down Expand Up @@ -38,6 +41,12 @@ export function StopPlace({ departures }: StopPlaceProps) {
image={`api/departures/open-graph?stopPlaceId=${departures.stopPlace.id}`}
/>

{/* Hard coded to norwegian as this should be the default for sharing links where
we dont know what language to show. */}
<OpenGraphDescription
description={`Sanntidsoversikt over alle avganger og holdeplasser fra ${departures.stopPlace.name}.`}
/>

<ScreenReaderOnly
text={t(PageText.Departures.stopPlace.quaySection.resultsLoaded)}
role="status"
Expand Down

0 comments on commit 7aabde9

Please sign in to comment.