Skip to content

Commit

Permalink
Merge pull request #75 from Georiviere/handle_external_links_on_detai…
Browse files Browse the repository at this point in the history
…l_pages

Feat: Add button to redirect user to external page if link on content
  • Loading branch information
Bo-Duke committed May 3, 2024
2 parents 6cd31a2 + 6abcf19 commit 766fa4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/details.page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Attachement } from '@/api/settings';
import { LatLngTuple } from 'leaflet';
import { useTranslations } from 'next-intl';

import { convertAttachementsToImages } from '@/lib/utils';

import ButtonCenterView from './button-center-view';
import ButtonClose from './button-close';
import Carousel from './carousel';
import { MetadataList } from './metadata-list';
import LinkAsButton from './ui/link-as-button';

type Props = {
content: {
Expand All @@ -16,6 +18,7 @@ type Props = {
length?: number;
descent?: number;
flow?: string;
url?: string;
geometryCenter?: {
type: 'Point';
coordinates: [number, number];
Expand All @@ -31,6 +34,7 @@ type Props = {
};

export default function DetailsPageUI({ content }: Props) {
const t = useTranslations('details');
return (
<article>
{content?.attachments?.length > 0 && (
Expand Down Expand Up @@ -66,6 +70,11 @@ export default function DetailsPageUI({ content }: Props) {
</header>

<div dangerouslySetInnerHTML={{ __html: content.description }} />
{content?.url && (
<LinkAsButton className="mx-auto mt-4 block w-fit" href={content?.url}>
{t('link')}
</LinkAsButton>
)}
</article>
);
}
3 changes: 2 additions & 1 deletion translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"m": "m",
"meters": "mètres",
"observationTypes": "Types d'observations",
"observations": "Observations"
"observations": "Observations",
"link": "Voir le site associé"
},
"home": {
"title": "Sentinelle des rivières : j'observe, je protège",
Expand Down

0 comments on commit 766fa4a

Please sign in to comment.