docs: move edit date to footer (#11667)
* docs: move edit date to footer * fix build error
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user