diff --git a/src/components/Nav/index.astro b/src/components/Nav/index.astro index 320add0aef..50f71c6d4c 100644 --- a/src/components/Nav/index.astro +++ b/src/components/Nav/index.astro @@ -1,6 +1,5 @@ --- import { getCurrentLocale, getUiTranslator } from "@/src/i18n/utils"; -import { jumpToState } from "@/src/globals/state"; import styles from "./styles.module.scss"; import { NavPanels } from "./NavPanels"; @@ -9,6 +8,7 @@ const currentLocale = getCurrentLocale(Astro.url.pathname); const pathMinusLocale = Astro.url.pathname.replace(`/${currentLocale}`, ""); const isHomepage = pathMinusLocale === "/"; const t = await getUiTranslator(currentLocale); +const { jumpToState } = Astro.props; const mainLinks = [ { url: "/reference/", label: t("Reference") }, diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 76e040a196..9bc1f54334 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -7,6 +7,7 @@ import ItemPageHeader from "@/src/components/PageHeader/ItemPage.astro"; import HomePageHeader from "@/src/components/PageHeader/HomePage.astro"; import { getCurrentLocale, getUiTranslator } from "@i18n/utils"; import { capitalize, getTopicInfo, type PageTopic } from "../pages/_utils"; +import { type JumpToState } from "@src/globals/state"; import "@styles/base.scss"; import type { CollectionEntry } from "astro:content"; import { getCollectionInLocaleWithFallbacks } from "@pages/_utils"; @@ -21,6 +22,7 @@ interface Props { variant?: "root" | "item" | "search" | "homepage"; topic?: PageTopic; mainContentParentClass?: string; + jumpToState?: JumpToState | null; /* Only needed for the homepage */ homepageConfig?: CollectionEntry<"homepage">; } @@ -34,6 +36,7 @@ const { variant = "root", mainContentParentClass = "mx-5 md:mx-lg mt-md", homepageConfig, + jumpToState } = Astro.props; const currentLocale = getCurrentLocale(Astro.url.pathname); @@ -87,7 +90,7 @@ const headerTopic = topic
{t("peoplePage", "PageDescription")}
diff --git a/src/layouts/ReferenceItemLayout.astro b/src/layouts/ReferenceItemLayout.astro index 49fab87dda..c95a153c4d 100644 --- a/src/layouts/ReferenceItemLayout.astro +++ b/src/layouts/ReferenceItemLayout.astro @@ -17,7 +17,6 @@ import type { ReferenceOverload, ReferenceParam, } from "@/types/parsers.interface"; -import { setJumpToState } from "../globals/state"; import { p5Version } from "../globals/p5-version"; import flask from "@src/content/ui/images/icons/flask.svg?raw"; import warning from "@src/content/ui/images/icons/warning.svg?raw"; @@ -59,8 +58,6 @@ relatedEntriesLinks.unshift({ // Put related links at top of the list jumpToState.links?.unshift(...relatedEntriesLinks); -setJumpToState(jumpToState); - // get whatever related entries might be specified in the collection entry data const relatedReferencesFromEntryData = entry.data.relatedContent?.references !== undefined @@ -110,6 +107,7 @@ function normalizeP5ReferenceLinks(html: string | undefined): string | undefined variant="item" topic="reference" className="reference-item" + jumpToState={jumpToState} > {showBanner &&