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