docs: move edit date to footer (#11667)
* docs: move edit date to footer * fix build error
This commit is contained in:
1 parent
228b7b608d
commit
bf67f69f45
23 files changed
+183
-121
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
import { TightLayout } from "docs-ui"
|
import { TightLayout } from "docs-ui"
|
||||||
import Feedback from "@/components/Feedback"
|
|
||||||
import EditButton from "@/components/EditButton"
|
|
||||||
import Providers from "../../providers"
|
import Providers from "../../providers"
|
||||||
|
import Footer from "../../components/Footer"
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children,
|
||||||
@@ -13,10 +12,8 @@ export default function RootLayout({
|
|||||||
sidebarProps={{
|
sidebarProps={{
|
||||||
expandItems: true,
|
expandItems: true,
|
||||||
}}
|
}}
|
||||||
showPagination={true}
|
|
||||||
feedbackComponent={<Feedback className="my-2" />}
|
|
||||||
editComponent={<EditButton />}
|
|
||||||
ProvidersComponent={Providers}
|
ProvidersComponent={Providers}
|
||||||
|
footerComponent={<Footer />}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</TightLayout>
|
</TightLayout>
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||||
import { TightLayout } from "docs-ui"
|
import { TightLayout } from "docs-ui"
|
||||||
import Feedback from "../components/Feedback"
|
|
||||||
import EditButton from "../components/EditButton"
|
|
||||||
import NotFoundContent from "./_not-found.mdx"
|
import NotFoundContent from "./_not-found.mdx"
|
||||||
import Providers from "../providers"
|
import Providers from "../providers"
|
||||||
|
import Footer from "../components/Footer"
|
||||||
|
|
||||||
const NotFoundPage = () => {
|
const NotFoundPage = () => {
|
||||||
return (
|
return (
|
||||||
@@ -11,9 +10,7 @@ const NotFoundPage = () => {
|
|||||||
sidebarProps={{
|
sidebarProps={{
|
||||||
expandItems: true,
|
expandItems: true,
|
||||||
}}
|
}}
|
||||||
showPagination={true}
|
footerComponent={<Footer />}
|
||||||
feedbackComponent={<Feedback className="my-2" />}
|
|
||||||
editComponent={<EditButton />}
|
|
||||||
ProvidersComponent={Providers}
|
ProvidersComponent={Providers}
|
||||||
>
|
>
|
||||||
{/* @ts-ignore React v19 doesn't recognize MDX import as component */}
|
{/* @ts-ignore React v19 doesn't recognize MDX import as component */}
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
|
|
||||||
import { EditButton as UiEditButton } from "docs-ui"
|
import { EditButton as UiEditButton } from "docs-ui"
|
||||||
import { usePathname } from "next/navigation"
|
import { usePathname } from "next/navigation"
|
||||||
|
import { useMemo } from "react"
|
||||||
|
import { generatedEditDates } from "../../generated/edit-dates.mjs"
|
||||||
|
|
||||||
const EditButton = () => {
|
const EditButton = () => {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
|
||||||
|
const editDate = useMemo(
|
||||||
|
() =>
|
||||||
|
(generatedEditDates as Record<string, string>)[
|
||||||
|
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
||||||
|
],
|
||||||
|
[pathname]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UiEditButton
|
<UiEditButton
|
||||||
filePath={`/www/apps/book/app${pathname.replace(/\/$/, "")}/page.mdx`}
|
filePath={`/www/apps/book/app${pathname.replace(/\/$/, "")}/page.mdx`}
|
||||||
|
editDate={editDate}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { Footer as UiFooter } from "docs-ui"
|
||||||
|
import Feedback from "../Feedback"
|
||||||
|
import EditButton from "../EditButton"
|
||||||
|
|
||||||
|
const Footer = () => {
|
||||||
|
return (
|
||||||
|
<UiFooter
|
||||||
|
showPagination={true}
|
||||||
|
feedbackComponent={<Feedback className="my-2" />}
|
||||||
|
editComponent={<EditButton />}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Footer
|
||||||
@@ -6,15 +6,12 @@ import {
|
|||||||
} from "docs-ui"
|
} from "docs-ui"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
import { usePathname } from "next/navigation"
|
|
||||||
import { generatedEditDates } from "../generated/edit-dates.mjs"
|
|
||||||
|
|
||||||
type MainNavProviderProps = {
|
type MainNavProviderProps = {
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
||||||
const pathname = usePathname()
|
|
||||||
const navigationDropdownItems = useMemo(
|
const navigationDropdownItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getNavDropdownItems({
|
getNavDropdownItems({
|
||||||
@@ -23,16 +20,8 @@ export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
|||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
const editDate = useMemo(
|
|
||||||
() =>
|
|
||||||
(generatedEditDates as Record<string, string>)[
|
|
||||||
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
|
||||||
],
|
|
||||||
[pathname]
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UiMainNavProvider navItems={navigationDropdownItems} editDate={editDate}>
|
<UiMainNavProvider navItems={navigationDropdownItems}>
|
||||||
{children}
|
{children}
|
||||||
</UiMainNavProvider>
|
</UiMainNavProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ import "./globals.css"
|
|||||||
import { BareboneLayout, TightLayout } from "docs-ui"
|
import { BareboneLayout, TightLayout } from "docs-ui"
|
||||||
import { config } from "@/config"
|
import { config } from "@/config"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import { Feedback } from "@/components/Feedback"
|
import Footer from "../components/Footer"
|
||||||
import EditButton from "@/components/EditButton"
|
|
||||||
|
|
||||||
const ogImage =
|
const ogImage =
|
||||||
"https://res.cloudinary.com/dza7lstvk/image/upload/v1732200992/Medusa%20Resources/opengraph-image_daq6nx.jpg"
|
"https://res.cloudinary.com/dza7lstvk/image/upload/v1732200992/Medusa%20Resources/opengraph-image_daq6nx.jpg"
|
||||||
@@ -68,9 +67,8 @@ export default function RootLayout({
|
|||||||
sidebarProps={{
|
sidebarProps={{
|
||||||
expandItems: true,
|
expandItems: true,
|
||||||
}}
|
}}
|
||||||
feedbackComponent={<Feedback className="my-2" />}
|
|
||||||
editComponent={<EditButton />}
|
|
||||||
ProvidersComponent={Providers}
|
ProvidersComponent={Providers}
|
||||||
|
footerComponent={<Footer />}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</TightLayout>
|
</TightLayout>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { usePathname } from "next/navigation"
|
|||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { EditButton as UiEditButton } from "docs-ui"
|
import { EditButton as UiEditButton } from "docs-ui"
|
||||||
import { filesMap } from "../../generated/files-map.mjs"
|
import { filesMap } from "../../generated/files-map.mjs"
|
||||||
|
import { generatedEditDates } from "../../generated/edit-dates.mjs"
|
||||||
|
|
||||||
const EditButton = () => {
|
const EditButton = () => {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
@@ -12,11 +13,19 @@ const EditButton = () => {
|
|||||||
[pathname]
|
[pathname]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const editDate = useMemo(
|
||||||
|
() =>
|
||||||
|
(generatedEditDates as Record<string, string>)[
|
||||||
|
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
||||||
|
],
|
||||||
|
[pathname]
|
||||||
|
)
|
||||||
|
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
|
||||||
return <UiEditButton filePath={filePath.filePath} />
|
return <UiEditButton filePath={filePath.filePath} editDate={editDate} />
|
||||||
}
|
}
|
||||||
|
|
||||||
export default EditButton
|
export default EditButton
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { Footer as UiFooter } from "docs-ui"
|
||||||
|
import { Feedback } from "../Feedback"
|
||||||
|
import EditButton from "../EditButton"
|
||||||
|
|
||||||
|
const Footer = () => {
|
||||||
|
return (
|
||||||
|
<UiFooter
|
||||||
|
showPagination={false}
|
||||||
|
feedbackComponent={<Feedback className="my-2" />}
|
||||||
|
editComponent={<EditButton />}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Footer
|
||||||
@@ -6,15 +6,12 @@ import {
|
|||||||
} from "docs-ui"
|
} from "docs-ui"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
import { usePathname } from "next/navigation"
|
|
||||||
import { generatedEditDates } from "../generated/edit-dates.mjs"
|
|
||||||
|
|
||||||
type MainNavProviderProps = {
|
type MainNavProviderProps = {
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
||||||
const pathname = usePathname()
|
|
||||||
const navigationDropdownItems = useMemo(
|
const navigationDropdownItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getNavDropdownItems({
|
getNavDropdownItems({
|
||||||
@@ -23,16 +20,8 @@ export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
|||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
const editDate = useMemo(
|
|
||||||
() =>
|
|
||||||
(generatedEditDates as Record<string, string>)[
|
|
||||||
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
|
||||||
],
|
|
||||||
[pathname]
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UiMainNavProvider navItems={navigationDropdownItems} editDate={editDate}>
|
<UiMainNavProvider navItems={navigationDropdownItems}>
|
||||||
{children}
|
{children}
|
||||||
</UiMainNavProvider>
|
</UiMainNavProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { config } from "@/config"
|
|||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import Feedback from "../components/Feedback"
|
import Feedback from "../components/Feedback"
|
||||||
import EditButton from "../components/EditButton"
|
import EditButton from "../components/EditButton"
|
||||||
|
import Footer from "../components/Footer"
|
||||||
|
|
||||||
const ogImage =
|
const ogImage =
|
||||||
"https://res.cloudinary.com/dza7lstvk/image/upload/v1732200992/Medusa%20Resources/opengraph-image_daq6nx.jpg"
|
"https://res.cloudinary.com/dza7lstvk/image/upload/v1732200992/Medusa%20Resources/opengraph-image_daq6nx.jpg"
|
||||||
@@ -68,6 +69,7 @@ export default function RootLayout({
|
|||||||
expandItems: true,
|
expandItems: true,
|
||||||
}}
|
}}
|
||||||
ProvidersComponent={Providers}
|
ProvidersComponent={Providers}
|
||||||
|
footerComponent={<Footer />}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
<Feedback className="my-2" />
|
<Feedback className="my-2" />
|
||||||
|
|||||||
@@ -2,16 +2,27 @@
|
|||||||
|
|
||||||
import { EditButton as UiEditButton } from "docs-ui"
|
import { EditButton as UiEditButton } from "docs-ui"
|
||||||
import { usePathname } from "next/navigation"
|
import { usePathname } from "next/navigation"
|
||||||
|
import { useMemo } from "react"
|
||||||
|
import { generatedEditDates } from "../../generated/edit-dates.mjs"
|
||||||
|
|
||||||
const EditButton = () => {
|
const EditButton = () => {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
|
|
||||||
|
const editDate = useMemo(
|
||||||
|
() =>
|
||||||
|
(generatedEditDates as Record<string, string>)[
|
||||||
|
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
||||||
|
],
|
||||||
|
[pathname]
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UiEditButton
|
<UiEditButton
|
||||||
filePath={`/www/apps/user-guide/app${pathname.replace(
|
filePath={`/www/apps/user-guide/app${pathname.replace(
|
||||||
/\/$/,
|
/\/$/,
|
||||||
""
|
""
|
||||||
)}/page.mdx`}
|
)}/page.mdx`}
|
||||||
|
editDate={editDate}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import { Footer as UiFooter } from "docs-ui"
|
||||||
|
import Feedback from "../Feedback"
|
||||||
|
import EditButton from "../EditButton"
|
||||||
|
|
||||||
|
const Footer = () => {
|
||||||
|
return (
|
||||||
|
<UiFooter
|
||||||
|
showPagination={true}
|
||||||
|
feedbackComponent={<Feedback className="my-2" />}
|
||||||
|
editComponent={<EditButton />}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Footer
|
||||||
@@ -6,15 +6,12 @@ import {
|
|||||||
} from "docs-ui"
|
} from "docs-ui"
|
||||||
import { useMemo } from "react"
|
import { useMemo } from "react"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
import { generatedEditDates } from "../generated/edit-dates.mjs"
|
|
||||||
import { usePathname } from "next/navigation"
|
|
||||||
|
|
||||||
type MainNavProviderProps = {
|
type MainNavProviderProps = {
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
||||||
const pathname = usePathname()
|
|
||||||
const navigationDropdownItems = useMemo(
|
const navigationDropdownItems = useMemo(
|
||||||
() =>
|
() =>
|
||||||
getNavDropdownItems({
|
getNavDropdownItems({
|
||||||
@@ -23,16 +20,8 @@ export const MainNavProvider = ({ children }: MainNavProviderProps) => {
|
|||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
|
|
||||||
const editDate = useMemo(
|
|
||||||
() =>
|
|
||||||
(generatedEditDates as Record<string, string>)[
|
|
||||||
`app${pathname.replace(/\/$/, "")}/page.mdx`
|
|
||||||
],
|
|
||||||
[pathname]
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<UiMainNavProvider navItems={navigationDropdownItems} editDate={editDate}>
|
<UiMainNavProvider navItems={navigationDropdownItems}>
|
||||||
{children}
|
{children}
|
||||||
</UiMainNavProvider>
|
</UiMainNavProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,23 +2,29 @@ import React from "react"
|
|||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import { ArrowUpRightOnBox } from "@medusajs/icons"
|
import { ArrowUpRightOnBox } from "@medusajs/icons"
|
||||||
|
import { EditDate } from "../EditDate"
|
||||||
|
|
||||||
type EditButtonProps = {
|
type EditButtonProps = {
|
||||||
filePath: string
|
filePath: string
|
||||||
|
editDate?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EditButton = ({ filePath }: EditButtonProps) => {
|
export const EditButton = ({ filePath, editDate }: EditButtonProps) => {
|
||||||
return (
|
return (
|
||||||
<Link
|
<div className="flex flex-wrap gap-docs_0.5 mt-docs_2 text-medusa-fg-subtle">
|
||||||
href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}
|
{editDate && <EditDate date={editDate} />}
|
||||||
className={clsx(
|
|
||||||
"flex w-fit gap-docs_0.25 my-docs_2 items-center",
|
<Link
|
||||||
"text-medusa-fg-muted hover:text-medusa-fg-subtle",
|
href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}
|
||||||
"text-compact-small-plus"
|
className={clsx(
|
||||||
)}
|
"flex w-fit gap-docs_0.25 items-center",
|
||||||
>
|
"text-medusa-fg-subtle hover:text-medusa-fg-base",
|
||||||
<span>Edit this page</span>
|
"text-compact-small-plus"
|
||||||
<ArrowUpRightOnBox />
|
)}
|
||||||
</Link>
|
>
|
||||||
|
<span>Edit this page</span>
|
||||||
|
<ArrowUpRightOnBox />
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
+2
-2
@@ -2,11 +2,11 @@ import React from "react"
|
|||||||
|
|
||||||
const DATE_REGEX = /^[a-zA-Z]+ (?<month>[a-zA-Z]+)/
|
const DATE_REGEX = /^[a-zA-Z]+ (?<month>[a-zA-Z]+)/
|
||||||
|
|
||||||
type MainNavEditDateProps = {
|
type EditDateProps = {
|
||||||
date: string
|
date: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MainNavEditDate = ({ date }: MainNavEditDateProps) => {
|
export const EditDate = ({ date }: EditDateProps) => {
|
||||||
const today = new Date(date)
|
const today = new Date(date)
|
||||||
const dateObj = new Date(date)
|
const dateObj = new Date(date)
|
||||||
const formattedDate = dateObj.toString()
|
const formattedDate = dateObj.toString()
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import React from "react"
|
||||||
|
import { Pagination } from "../Pagination"
|
||||||
|
|
||||||
|
export type FooterProps = {
|
||||||
|
editComponent?: React.ReactNode
|
||||||
|
showPagination?: boolean
|
||||||
|
feedbackComponent?: React.ReactNode
|
||||||
|
editDate?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Footer = ({
|
||||||
|
editComponent,
|
||||||
|
showPagination,
|
||||||
|
feedbackComponent,
|
||||||
|
}: FooterProps) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{feedbackComponent}
|
||||||
|
{showPagination && <Pagination />}
|
||||||
|
{editComponent}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -36,35 +36,30 @@ export const MainNavVersion = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Link
|
||||||
<Link
|
href={version.releaseUrl}
|
||||||
href={version.releaseUrl}
|
target="_blank"
|
||||||
target="_blank"
|
className={clsx(version.hide && "hidden")}
|
||||||
className={clsx(version.hide && "hidden")}
|
>
|
||||||
>
|
<Tooltip html="View the release notes<br/>on GitHub">
|
||||||
<Tooltip html="View the release notes<br/>on GitHub">
|
<span
|
||||||
<span
|
className="relative text-compact-small-plus block"
|
||||||
className="relative text-compact-small-plus block"
|
onMouseOut={afterHover}
|
||||||
onMouseOut={afterHover}
|
>
|
||||||
>
|
<span className="flex justify-center items-center">
|
||||||
<span className="flex justify-center items-center">
|
v{version.number}
|
||||||
v{version.number}
|
|
||||||
</span>
|
|
||||||
{showNewBadge && (
|
|
||||||
<span
|
|
||||||
className={clsx(
|
|
||||||
"bg-medusa-tag-blue-icon w-[10px] h-[10px]",
|
|
||||||
"absolute -top-docs_0.25 -right-docs_0.5",
|
|
||||||
"animate-pulse rounded-full"
|
|
||||||
)}
|
|
||||||
></span>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
{showNewBadge && (
|
||||||
</Link>
|
<span
|
||||||
<span className={clsx("text-compact-small", version.hide && "hidden")}>
|
className={clsx(
|
||||||
·
|
"bg-medusa-tag-blue-icon w-[10px] h-[10px]",
|
||||||
</span>
|
"absolute -top-docs_0.25 -right-docs_0.5",
|
||||||
</>
|
"animate-pulse rounded-full"
|
||||||
|
)}
|
||||||
|
></span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</Link>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -8,11 +8,9 @@ import {
|
|||||||
GITHUB_ISSUES_LINK,
|
GITHUB_ISSUES_LINK,
|
||||||
SearchModalOpener,
|
SearchModalOpener,
|
||||||
useLayout,
|
useLayout,
|
||||||
useMainNav,
|
|
||||||
useSidebar,
|
useSidebar,
|
||||||
useSiteConfig,
|
useSiteConfig,
|
||||||
} from "../.."
|
} from "../.."
|
||||||
import { MainNavEditDate } from "./EditDate"
|
|
||||||
import { MainNavItems } from "./Items"
|
import { MainNavItems } from "./Items"
|
||||||
import { MainNavDesktopMenu } from "./DesktopMenu"
|
import { MainNavDesktopMenu } from "./DesktopMenu"
|
||||||
import { SidebarLeftIcon } from "../Icons/SidebarLeft"
|
import { SidebarLeftIcon } from "../Icons/SidebarLeft"
|
||||||
@@ -28,7 +26,6 @@ type MainNavProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
||||||
const { editDate } = useMainNav()
|
|
||||||
const { setMobileSidebarOpen, isSidebarShown } = useSidebar()
|
const { setMobileSidebarOpen, isSidebarShown } = useSidebar()
|
||||||
const { config } = useSiteConfig()
|
const { config } = useSiteConfig()
|
||||||
const { showCollapsedNavbar } = useLayout()
|
const { showCollapsedNavbar } = useLayout()
|
||||||
@@ -68,13 +65,20 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
|||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"flex items-center gap-docs_0.75 my-docs_0.75",
|
"flex items-center my-docs_0.75",
|
||||||
showCollapsedNavbar && "flex-grow justify-between"
|
showCollapsedNavbar && "flex-grow justify-between"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="lg:flex items-center gap-docs_0.5 text-medusa-fg-subtle hidden">
|
<div className="lg:flex items-center gap-[6px] text-medusa-fg-subtle hidden">
|
||||||
<MainNavVersion />
|
<MainNavVersion />
|
||||||
{editDate && <MainNavEditDate date={editDate} />}
|
<span
|
||||||
|
className={clsx(
|
||||||
|
"text-compact-small",
|
||||||
|
config.version.hide && "hidden"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
·
|
||||||
|
</span>
|
||||||
<MainNavItemDropdown
|
<MainNavItemDropdown
|
||||||
item={{
|
item={{
|
||||||
type: "dropdown",
|
type: "dropdown",
|
||||||
@@ -109,8 +113,11 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
|||||||
className="text-medusa-fg-subtle"
|
className="text-medusa-fg-subtle"
|
||||||
wrapperClassName="z-10"
|
wrapperClassName="z-10"
|
||||||
/>
|
/>
|
||||||
|
{!showCollapsedNavbar && (
|
||||||
|
<span className={clsx("text-compact-small")}>·</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-docs_0.25">
|
<div className="flex items-center">
|
||||||
<AiAssistantTriggerButton />
|
<AiAssistantTriggerButton />
|
||||||
<SearchModalOpener />
|
<SearchModalOpener />
|
||||||
<MainNavDesktopMenu />
|
<MainNavDesktopMenu />
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export * from "./ExpandableNotice"
|
|||||||
export * from "./FeatureFlagNotice"
|
export * from "./FeatureFlagNotice"
|
||||||
export * from "./Feedback"
|
export * from "./Feedback"
|
||||||
export * from "./Feedback/Solutions"
|
export * from "./Feedback/Solutions"
|
||||||
|
export * from "./Footer"
|
||||||
export * from "./Heading"
|
export * from "./Heading"
|
||||||
export * from "./HooksLoader"
|
export * from "./HooksLoader"
|
||||||
export * from "./IconHeadline"
|
export * from "./IconHeadline"
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ export type RootLayoutProps = {
|
|||||||
bodyClassName?: string
|
bodyClassName?: string
|
||||||
showToc?: boolean
|
showToc?: boolean
|
||||||
sidebarProps?: SidebarProps
|
sidebarProps?: SidebarProps
|
||||||
showPagination?: boolean
|
|
||||||
feedbackComponent?: React.ReactNode
|
|
||||||
editComponent?: React.ReactNode
|
|
||||||
showBreadcrumbs?: boolean
|
showBreadcrumbs?: boolean
|
||||||
ProvidersComponent: React.FC<{ children: React.ReactNode }>
|
ProvidersComponent: React.FC<{ children: React.ReactNode }>
|
||||||
|
footerComponent?: React.ReactNode
|
||||||
} & MainContentLayoutProps
|
} & MainContentLayoutProps
|
||||||
|
|
||||||
export const RootLayout = ({
|
export const RootLayout = ({
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { RootLayout, RootLayoutProps } from "./root"
|
import { RootLayout, RootLayoutProps } from "./root"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import { Breadcrumbs, Pagination } from ".."
|
import { Breadcrumbs } from ".."
|
||||||
|
|
||||||
export const TightLayout = ({
|
export const TightLayout = ({
|
||||||
children,
|
children,
|
||||||
showPagination,
|
footerComponent,
|
||||||
feedbackComponent,
|
|
||||||
editComponent,
|
|
||||||
showBreadcrumbs = true,
|
showBreadcrumbs = true,
|
||||||
...props
|
...props
|
||||||
}: RootLayoutProps) => {
|
}: RootLayoutProps) => {
|
||||||
@@ -24,9 +22,7 @@ export const TightLayout = ({
|
|||||||
>
|
>
|
||||||
{showBreadcrumbs && <Breadcrumbs />}
|
{showBreadcrumbs && <Breadcrumbs />}
|
||||||
{children}
|
{children}
|
||||||
{feedbackComponent}
|
{footerComponent}
|
||||||
{showPagination && <Pagination />}
|
|
||||||
{editComponent}
|
|
||||||
</div>
|
</div>
|
||||||
</RootLayout>
|
</RootLayout>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { RootLayout, RootLayoutProps } from "./root"
|
import { RootLayout, RootLayoutProps } from "./root"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import { Breadcrumbs, Pagination } from ".."
|
import { Breadcrumbs } from ".."
|
||||||
|
|
||||||
export const WideLayout = ({
|
export const WideLayout = ({
|
||||||
children,
|
children,
|
||||||
showPagination,
|
footerComponent,
|
||||||
feedbackComponent,
|
|
||||||
editComponent,
|
|
||||||
showBreadcrumbs = true,
|
showBreadcrumbs = true,
|
||||||
...props
|
...props
|
||||||
}: RootLayoutProps) => {
|
}: RootLayoutProps) => {
|
||||||
@@ -20,9 +18,7 @@ export const WideLayout = ({
|
|||||||
<main className={clsx("relative mt-4 w-full flex-1 lg:mt-7")}>
|
<main className={clsx("relative mt-4 w-full flex-1 lg:mt-7")}>
|
||||||
{showBreadcrumbs && <Breadcrumbs />}
|
{showBreadcrumbs && <Breadcrumbs />}
|
||||||
{children}
|
{children}
|
||||||
{feedbackComponent}
|
{footerComponent}
|
||||||
{showPagination && <Pagination />}
|
|
||||||
{editComponent}
|
|
||||||
</main>
|
</main>
|
||||||
</RootLayout>
|
</RootLayout>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ const MainNavContext = createContext<MainNavContext | null>(null)
|
|||||||
|
|
||||||
export type MainNavProviderProps = {
|
export type MainNavProviderProps = {
|
||||||
navItems: NavigationItem[]
|
navItems: NavigationItem[]
|
||||||
editDate?: string
|
|
||||||
children?: React.ReactNode
|
children?: React.ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MainNavProvider = ({
|
export const MainNavProvider = ({
|
||||||
navItems,
|
navItems,
|
||||||
children,
|
children,
|
||||||
editDate,
|
|
||||||
}: MainNavProviderProps) => {
|
}: MainNavProviderProps) => {
|
||||||
const pathname = usePathname()
|
const pathname = usePathname()
|
||||||
const { config } = useSiteConfig()
|
const { config } = useSiteConfig()
|
||||||
@@ -87,7 +85,6 @@ export const MainNavProvider = ({
|
|||||||
value={{
|
value={{
|
||||||
navItems,
|
navItems,
|
||||||
activeItemIndex,
|
activeItemIndex,
|
||||||
editDate,
|
|
||||||
activeItem,
|
activeItem,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user