docs: improv version detection + fix breadcrumbs (#10083)
This commit is contained in:
@@ -523,8 +523,8 @@ export const sidebar = numberSidebarItems(
|
||||
{
|
||||
type: "link",
|
||||
title: "Environment Variables",
|
||||
path: "/learn/advanced-development/environment-variables"
|
||||
}
|
||||
path: "/learn/advanced-development/environment-variables",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -607,8 +607,8 @@ export const sidebar = numberSidebarItems(
|
||||
type: "link",
|
||||
path: "/learn/deployment/general",
|
||||
title: "General Deployment",
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
|
||||
Vendored
-1
@@ -3,7 +3,6 @@ import { SidebarSectionItems, SidebarItem as SidebarItemType } from "types"
|
||||
export declare type SidebarItem = SidebarItemType & {
|
||||
isSoon: boolean
|
||||
number?: string
|
||||
chapterTitle?: string
|
||||
}
|
||||
|
||||
export declare type SidebarConfig = SidebarSectionItems
|
||||
|
||||
@@ -50,7 +50,10 @@ export const Breadcrumbs = () => {
|
||||
|
||||
tempBreadcrumbItems.set(
|
||||
breadcrumbPath,
|
||||
item.parentItem?.childSidebarTitle || item.parentItem?.title || ""
|
||||
item.parentItem?.childSidebarTitle ||
|
||||
item.parentItem?.chapterTitle ||
|
||||
item.parentItem?.title ||
|
||||
""
|
||||
)
|
||||
|
||||
return tempBreadcrumbItems
|
||||
@@ -76,12 +79,14 @@ export const Breadcrumbs = () => {
|
||||
sidebarActiveItem.parentItem.type === "link"
|
||||
? getLinkPath(sidebarActiveItem.parentItem) || "#"
|
||||
: "#",
|
||||
sidebarActiveItem.parentItem.title || ""
|
||||
sidebarActiveItem.parentItem.chapterTitle ||
|
||||
sidebarActiveItem.parentItem.title ||
|
||||
""
|
||||
)
|
||||
}
|
||||
tempBreadcrumbItems.set(
|
||||
getLinkPath(sidebarActiveItem) || "/",
|
||||
sidebarActiveItem.title || ""
|
||||
sidebarActiveItem.chapterTitle || sidebarActiveItem.title || ""
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"use state"
|
||||
|
||||
import React, { useEffect, useMemo, useState } from "react"
|
||||
import React, { useEffect, useState } from "react"
|
||||
import { useIsBrowser, useSiteConfig } from "../../../providers"
|
||||
import Link from "next/link"
|
||||
import { Tooltip } from "../../Tooltip"
|
||||
import clsx from "clsx"
|
||||
|
||||
const LOCAL_STORAGE_SUFFIX = "-seen"
|
||||
const LOCAL_STORAGE_SUFFIX = "last-version"
|
||||
|
||||
export const MainNavVersion = () => {
|
||||
const {
|
||||
@@ -14,20 +14,17 @@ export const MainNavVersion = () => {
|
||||
} = useSiteConfig()
|
||||
const [showNewBadge, setShowNewBadge] = useState(false)
|
||||
const { isBrowser } = useIsBrowser()
|
||||
const localStorageKey = useMemo(
|
||||
() => `${version.number}${LOCAL_STORAGE_SUFFIX}`,
|
||||
[version]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isBrowser) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!localStorage.getItem(localStorageKey)) {
|
||||
const storedVersion = localStorage.getItem(LOCAL_STORAGE_SUFFIX)
|
||||
if (storedVersion !== version.number) {
|
||||
setShowNewBadge(true)
|
||||
}
|
||||
}, [isBrowser, localStorageKey])
|
||||
}, [isBrowser])
|
||||
|
||||
const afterHover = () => {
|
||||
if (!showNewBadge) {
|
||||
@@ -35,7 +32,7 @@ export const MainNavVersion = () => {
|
||||
}
|
||||
|
||||
setShowNewBadge(false)
|
||||
localStorage.setItem(localStorageKey, "true")
|
||||
localStorage.setItem(LOCAL_STORAGE_SUFFIX, version.number)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -7,4 +7,4 @@ export const globalConfig: Pick<DocsConfig, "version"> = {
|
||||
"number": "2.0.4",
|
||||
"releaseUrl": "https://github.com/medusajs/medusa/releases/tag/v2.0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export type SidebarItemCommon = {
|
||||
childSidebarTitle?: string
|
||||
loaded?: boolean
|
||||
additionalElms?: React.ReactNode
|
||||
chapterTitle?: string
|
||||
}
|
||||
|
||||
export type SidebarItemLink = SidebarItemCommon & {
|
||||
|
||||
Reference in New Issue
Block a user