Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: improv version detection + fix breadcrumbs #10083

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions www/apps/book/sidebar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
],
},
{
Expand Down Expand Up @@ -607,8 +607,8 @@ export const sidebar = numberSidebarItems(
type: "link",
path: "/learn/deployment/general",
title: "General Deployment",
}
]
},
],
},
{
type: "link",
Expand Down
1 change: 0 additions & 1 deletion www/apps/book/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 8 additions & 3 deletions www/packages/docs-ui/src/components/Breadcrumbs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 || ""
)
}

Expand Down
15 changes: 6 additions & 9 deletions www/packages/docs-ui/src/components/MainNav/Version/index.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,38 @@
"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 {
config: { version },
} = 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) {
return
}

setShowNewBadge(false)
localStorage.setItem(localStorageKey, "true")
localStorage.setItem(LOCAL_STORAGE_SUFFIX, version.number)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion www/packages/docs-ui/src/global-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
1 change: 1 addition & 0 deletions www/packages/types/src/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type SidebarItemCommon = {
childSidebarTitle?: string
loaded?: boolean
additionalElms?: React.ReactNode
chapterTitle?: string
}

export type SidebarItemLink = SidebarItemCommon & {
Expand Down
Loading