docs: add routing page (#9550)

- Add a new homepage to `book` project for the routing page
- Move all main doc pages to be under `/v2/learn` (and added redirects + fixed links across docs)
- Other: add admin components to resources dropdown + fixes to search on mobile.

Closes DX-955

Preview: https://docs-v2-git-docs-router-page-medusajs.vercel.app/v2
This commit is contained in:
Shahed Nasser
2024-10-18 11:24:34 +03:00
committed by GitHub
parent 7a47f5211d
commit 0a37675f0e
223 changed files with 2549 additions and 696 deletions

View File

@@ -6,7 +6,7 @@ import {
SidebarLeft,
TimelineVertical,
} from "@medusajs/icons"
import React, { useRef, useState } from "react"
import React, { useMemo, useRef, useState } from "react"
import {
Button,
getOsShortcut,
@@ -17,10 +17,11 @@ import {
import clsx from "clsx"
import { HouseIcon } from "../../Icons/House"
import { MainNavThemeMenu } from "./ThemeMenu"
import { MenuItem } from "types"
export const MainNavDesktopMenu = () => {
const [isOpen, setIsOpen] = useState(false)
const { setDesktopSidebarOpen } = useSidebar()
const { setDesktopSidebarOpen, isSidebarShown } = useSidebar()
const ref = useRef(null)
useClickOutside({
@@ -28,6 +29,59 @@ export const MainNavDesktopMenu = () => {
onClickOutside: () => setIsOpen(false),
})
const items: MenuItem[] = useMemo(() => {
const items: MenuItem[] = [
{
type: "link",
icon: <HouseIcon />,
title: "Homepage",
link: "https://docs.medusajs.com/v2",
},
{
type: "link",
icon: <TimelineVertical />,
title: "Changelog",
link: "https://medusajs.com/changelog",
},
{
type: "link",
icon: <QuestionMarkCircle />,
title: "Troubleshooting",
link: "https://docs.medusajs.com/v2/resources/troubleshooting",
},
]
if (isSidebarShown) {
items.push(
{
type: "divider",
},
{
type: "action",
title: "Hide Sidebar",
icon: <SidebarLeft />,
shortcut: `${getOsShortcut()}\\`,
action: () => {
setDesktopSidebarOpen((prev) => !prev)
setIsOpen(false)
},
}
)
}
items.push(
{
type: "divider",
},
{
type: "custom",
content: <MainNavThemeMenu />,
}
)
return items
}, [isSidebarShown])
return (
<div
className="relative hidden lg:flex justify-center items-center"
@@ -45,46 +99,7 @@ export const MainNavDesktopMenu = () => {
"absolute top-[calc(100%+8px)] right-0 min-w-[200px]",
!isOpen && "hidden"
)}
items={[
{
type: "link",
icon: <HouseIcon />,
title: "Homepage",
link: "https://medusajs.com",
},
{
type: "link",
icon: <TimelineVertical />,
title: "Changelog",
link: "https://medusajs.com/changelog",
},
{
type: "link",
icon: <QuestionMarkCircle />,
title: "Troubleshooting",
link: "https://docs.medusajs.com/v2/resources/troubleshooting",
},
{
type: "divider",
},
{
type: "action",
title: "Hide Sidebar",
icon: <SidebarLeft />,
shortcut: `${getOsShortcut()}\\`,
action: () => {
setDesktopSidebarOpen((prev) => !prev)
setIsOpen(false)
},
},
{
type: "divider",
},
{
type: "custom",
content: <MainNavThemeMenu />,
},
]}
items={items}
/>
</div>
)