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
@@ -2,23 +2,29 @@ import React from "react"
|
||||
import Link from "next/link"
|
||||
import clsx from "clsx"
|
||||
import { ArrowUpRightOnBox } from "@medusajs/icons"
|
||||
import { EditDate } from "../EditDate"
|
||||
|
||||
type EditButtonProps = {
|
||||
filePath: string
|
||||
editDate?: string
|
||||
}
|
||||
|
||||
export const EditButton = ({ filePath }: EditButtonProps) => {
|
||||
export const EditButton = ({ filePath, editDate }: EditButtonProps) => {
|
||||
return (
|
||||
<Link
|
||||
href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}
|
||||
className={clsx(
|
||||
"flex w-fit gap-docs_0.25 my-docs_2 items-center",
|
||||
"text-medusa-fg-muted hover:text-medusa-fg-subtle",
|
||||
"text-compact-small-plus"
|
||||
)}
|
||||
>
|
||||
<span>Edit this page</span>
|
||||
<ArrowUpRightOnBox />
|
||||
</Link>
|
||||
<div className="flex flex-wrap gap-docs_0.5 mt-docs_2 text-medusa-fg-subtle">
|
||||
{editDate && <EditDate date={editDate} />}
|
||||
|
||||
<Link
|
||||
href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}
|
||||
className={clsx(
|
||||
"flex w-fit gap-docs_0.25 items-center",
|
||||
"text-medusa-fg-subtle hover:text-medusa-fg-base",
|
||||
"text-compact-small-plus"
|
||||
)}
|
||||
>
|
||||
<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]+)/
|
||||
|
||||
type MainNavEditDateProps = {
|
||||
type EditDateProps = {
|
||||
date: string
|
||||
}
|
||||
|
||||
export const MainNavEditDate = ({ date }: MainNavEditDateProps) => {
|
||||
export const EditDate = ({ date }: EditDateProps) => {
|
||||
const today = new Date(date)
|
||||
const dateObj = new Date(date)
|
||||
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 (
|
||||
<>
|
||||
<Link
|
||||
href={version.releaseUrl}
|
||||
target="_blank"
|
||||
className={clsx(version.hide && "hidden")}
|
||||
>
|
||||
<Tooltip html="View the release notes<br/>on GitHub">
|
||||
<span
|
||||
className="relative text-compact-small-plus block"
|
||||
onMouseOut={afterHover}
|
||||
>
|
||||
<span className="flex justify-center items-center">
|
||||
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>
|
||||
)}
|
||||
<Link
|
||||
href={version.releaseUrl}
|
||||
target="_blank"
|
||||
className={clsx(version.hide && "hidden")}
|
||||
>
|
||||
<Tooltip html="View the release notes<br/>on GitHub">
|
||||
<span
|
||||
className="relative text-compact-small-plus block"
|
||||
onMouseOut={afterHover}
|
||||
>
|
||||
<span className="flex justify-center items-center">
|
||||
v{version.number}
|
||||
</span>
|
||||
</Tooltip>
|
||||
</Link>
|
||||
<span className={clsx("text-compact-small", version.hide && "hidden")}>
|
||||
·
|
||||
</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>
|
||||
</Tooltip>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import {
|
||||
GITHUB_ISSUES_LINK,
|
||||
SearchModalOpener,
|
||||
useLayout,
|
||||
useMainNav,
|
||||
useSidebar,
|
||||
useSiteConfig,
|
||||
} from "../.."
|
||||
import { MainNavEditDate } from "./EditDate"
|
||||
import { MainNavItems } from "./Items"
|
||||
import { MainNavDesktopMenu } from "./DesktopMenu"
|
||||
import { SidebarLeftIcon } from "../Icons/SidebarLeft"
|
||||
@@ -28,7 +26,6 @@ type MainNavProps = {
|
||||
}
|
||||
|
||||
export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
||||
const { editDate } = useMainNav()
|
||||
const { setMobileSidebarOpen, isSidebarShown } = useSidebar()
|
||||
const { config } = useSiteConfig()
|
||||
const { showCollapsedNavbar } = useLayout()
|
||||
@@ -68,13 +65,20 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
||||
)}
|
||||
<div
|
||||
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"
|
||||
)}
|
||||
>
|
||||
<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 />
|
||||
{editDate && <MainNavEditDate date={editDate} />}
|
||||
<span
|
||||
className={clsx(
|
||||
"text-compact-small",
|
||||
config.version.hide && "hidden"
|
||||
)}
|
||||
>
|
||||
·
|
||||
</span>
|
||||
<MainNavItemDropdown
|
||||
item={{
|
||||
type: "dropdown",
|
||||
@@ -109,8 +113,11 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
|
||||
className="text-medusa-fg-subtle"
|
||||
wrapperClassName="z-10"
|
||||
/>
|
||||
{!showCollapsedNavbar && (
|
||||
<span className={clsx("text-compact-small")}>·</span>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex items-center gap-docs_0.25">
|
||||
<div className="flex items-center">
|
||||
<AiAssistantTriggerButton />
|
||||
<SearchModalOpener />
|
||||
<MainNavDesktopMenu />
|
||||
|
||||
@@ -24,6 +24,7 @@ export * from "./ExpandableNotice"
|
||||
export * from "./FeatureFlagNotice"
|
||||
export * from "./Feedback"
|
||||
export * from "./Feedback/Solutions"
|
||||
export * from "./Footer"
|
||||
export * from "./Heading"
|
||||
export * from "./HooksLoader"
|
||||
export * from "./IconHeadline"
|
||||
|
||||
@@ -9,11 +9,9 @@ export type RootLayoutProps = {
|
||||
bodyClassName?: string
|
||||
showToc?: boolean
|
||||
sidebarProps?: SidebarProps
|
||||
showPagination?: boolean
|
||||
feedbackComponent?: React.ReactNode
|
||||
editComponent?: React.ReactNode
|
||||
showBreadcrumbs?: boolean
|
||||
ProvidersComponent: React.FC<{ children: React.ReactNode }>
|
||||
footerComponent?: React.ReactNode
|
||||
} & MainContentLayoutProps
|
||||
|
||||
export const RootLayout = ({
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import React from "react"
|
||||
import { RootLayout, RootLayoutProps } from "./root"
|
||||
import clsx from "clsx"
|
||||
import { Breadcrumbs, Pagination } from ".."
|
||||
import { Breadcrumbs } from ".."
|
||||
|
||||
export const TightLayout = ({
|
||||
children,
|
||||
showPagination,
|
||||
feedbackComponent,
|
||||
editComponent,
|
||||
footerComponent,
|
||||
showBreadcrumbs = true,
|
||||
...props
|
||||
}: RootLayoutProps) => {
|
||||
@@ -24,9 +22,7 @@ export const TightLayout = ({
|
||||
>
|
||||
{showBreadcrumbs && <Breadcrumbs />}
|
||||
{children}
|
||||
{feedbackComponent}
|
||||
{showPagination && <Pagination />}
|
||||
{editComponent}
|
||||
{footerComponent}
|
||||
</div>
|
||||
</RootLayout>
|
||||
)
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import React from "react"
|
||||
import { RootLayout, RootLayoutProps } from "./root"
|
||||
import clsx from "clsx"
|
||||
import { Breadcrumbs, Pagination } from ".."
|
||||
import { Breadcrumbs } from ".."
|
||||
|
||||
export const WideLayout = ({
|
||||
children,
|
||||
showPagination,
|
||||
feedbackComponent,
|
||||
editComponent,
|
||||
footerComponent,
|
||||
showBreadcrumbs = true,
|
||||
...props
|
||||
}: RootLayoutProps) => {
|
||||
@@ -20,9 +18,7 @@ export const WideLayout = ({
|
||||
<main className={clsx("relative mt-4 w-full flex-1 lg:mt-7")}>
|
||||
{showBreadcrumbs && <Breadcrumbs />}
|
||||
{children}
|
||||
{feedbackComponent}
|
||||
{showPagination && <Pagination />}
|
||||
{editComponent}
|
||||
{footerComponent}
|
||||
</main>
|
||||
</RootLayout>
|
||||
)
|
||||
|
||||
@@ -16,14 +16,12 @@ const MainNavContext = createContext<MainNavContext | null>(null)
|
||||
|
||||
export type MainNavProviderProps = {
|
||||
navItems: NavigationItem[]
|
||||
editDate?: string
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const MainNavProvider = ({
|
||||
navItems,
|
||||
children,
|
||||
editDate,
|
||||
}: MainNavProviderProps) => {
|
||||
const pathname = usePathname()
|
||||
const { config } = useSiteConfig()
|
||||
@@ -87,7 +85,6 @@ export const MainNavProvider = ({
|
||||
value={{
|
||||
navItems,
|
||||
activeItemIndex,
|
||||
editDate,
|
||||
activeItem,
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in new issue
Block a user