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 && } +