From 6846de88109e3c586493361a461f10e4b2f2adb4 Mon Sep 17 00:00:00 2001 From: Sylvain Lafay Date: Mon, 30 Sep 2024 17:42:37 +0200 Subject: [PATCH] feat(newsletter): n'affiche pas Follow sur les pages newsletter_ --- assets/components/Layout/AppFollow.tsx | 13 ++++++++++++- assets/components/Layout/AppLayout.tsx | 4 +--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/assets/components/Layout/AppFollow.tsx b/assets/components/Layout/AppFollow.tsx index cfefc6cb..3c455fa6 100644 --- a/assets/components/Layout/AppFollow.tsx +++ b/assets/components/Layout/AppFollow.tsx @@ -1,8 +1,19 @@ import { memo } from "react"; import Follow from "@codegouvfr/react-dsfr/Follow"; -import { routes } from "../../router/router"; +import { routes, useRoute } from "../../router/router"; const AppFollow = () => { + const newsletterSubscribeAction = (document.getElementById("app_env") as HTMLDivElement)?.dataset?.["newsletterSubscribeAction"] ?? null; + const route = useRoute(); + + if (newsletterSubscribeAction === null) { + return null; + } + + if (typeof route.name === "string" && /^newsletter_/.test(route.name)) { + return null; + } + return ( > = ({ children, navItems, return getBreadcrumb(route, datastoreQuery.data); }, [route, datastoreQuery.data, customBreadcrumbProps]); - const newsletterSubscribeAction = (document.getElementById("app_env") as HTMLDivElement)?.dataset?.["newsletterSubscribeAction"] ?? null; - navItems = useMemo(() => navItems ?? defaultNavItems(t), [navItems, t]); return ( @@ -93,7 +91,7 @@ const AppLayout: FC> = ({ children, navItems, {children} - {newsletterSubscribeAction !== null && } +