docs: update api-reference project for v2 (#7307)
* remove everything v1 and make v2 default * move main v2 rewrites to book * move rewrites to book + other fixes
This commit is contained in:
@@ -18,7 +18,7 @@ export const NavbarLink = ({
|
||||
label,
|
||||
className,
|
||||
isActive,
|
||||
badge
|
||||
badge,
|
||||
}: NavbarLinkProps) => {
|
||||
return (
|
||||
<Link
|
||||
@@ -32,10 +32,9 @@ export const NavbarLink = ({
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
{badge && <Badge {...badge} className={clsx(
|
||||
badge.className,
|
||||
"ml-docs_0.5"
|
||||
)} />}
|
||||
{badge && (
|
||||
<Badge {...badge} className={clsx(badge.className, "ml-docs_0.5")} />
|
||||
)}
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,9 +3,8 @@ import React from "react"
|
||||
|
||||
export const NavbarDivider = () => {
|
||||
return (
|
||||
<div className={clsx(
|
||||
"w-px h-1/2 bg-medusa-fg-disabled",
|
||||
"mx-docs_0.5"
|
||||
)}></div>
|
||||
<div
|
||||
className={clsx("w-px h-1/2 bg-medusa-fg-disabled", "mx-docs_0.5")}
|
||||
></div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,15 @@ import { NavbarSearchModalOpener } from "./SearchModalOpener"
|
||||
import { NavbarMobileMenuButtonProps } from "./MobileMenu/Button"
|
||||
import { NavbarDivider } from "./NavbarDivider"
|
||||
|
||||
export type NavbarItem = {
|
||||
type: "link"
|
||||
props: NavbarLinkProps
|
||||
} | {
|
||||
type: "divider"
|
||||
props?: {}
|
||||
}
|
||||
export type NavbarItem =
|
||||
| {
|
||||
type: "link"
|
||||
props: NavbarLinkProps
|
||||
}
|
||||
| {
|
||||
type: "divider"
|
||||
props?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type NavbarProps = {
|
||||
logo: NavbarLogoProps
|
||||
@@ -54,10 +56,10 @@ export const Navbar = ({
|
||||
>
|
||||
<div className="hidden w-full items-center gap-docs_0.5 lg:flex lg:w-auto lg:gap-docs_1.5">
|
||||
<NavbarLogo {...logo} />
|
||||
{items.map(({type, props}, index) => {
|
||||
switch(type) {
|
||||
{items.map(({ type, props }, index) => {
|
||||
switch (type) {
|
||||
case "divider":
|
||||
return <NavbarDivider key={index} />
|
||||
return <NavbarDivider key={index} />
|
||||
default:
|
||||
return <NavbarLink key={index} {...props} />
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ export const Search = ({
|
||||
indexName={algolia.mainIndexName}
|
||||
searchClient={searchClient}
|
||||
future={{
|
||||
preserveSharedStateOnUnmount: true
|
||||
preserveSharedStateOnUnmount: true,
|
||||
}}
|
||||
>
|
||||
<div className={clsx("bg-medusa-bg-base flex")}>
|
||||
|
||||
@@ -27,7 +27,7 @@ export const SidebarItem = ({
|
||||
className,
|
||||
currentLevel = 1,
|
||||
sidebarHasParent = false,
|
||||
isMobile = false
|
||||
isMobile = false,
|
||||
}: SidebarItemProps) => {
|
||||
const [showLoading, setShowLoading] = useState(false)
|
||||
const {
|
||||
|
||||
@@ -42,7 +42,9 @@ const TypeListItem = ({
|
||||
}: TypeListItemProps) => {
|
||||
const isBrowser = useIsBrowser()
|
||||
const pathname = usePathname()
|
||||
const { config: { baseUrl, basePath } } = useSiteConfig()
|
||||
const {
|
||||
config: { baseUrl, basePath },
|
||||
} = useSiteConfig()
|
||||
const siteUrl = `${baseUrl}${basePath}`
|
||||
|
||||
const groupName = useMemo(() => {
|
||||
|
||||
@@ -89,42 +89,13 @@ export const navbarItemsV2: NavbarItem[] = [
|
||||
href: `/v2/resources`,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "divider",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
props: {
|
||||
label: "Docs",
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
href: `/`,
|
||||
badge: {
|
||||
variant: "neutral",
|
||||
children: "v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
props: {
|
||||
label: "User Guide",
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
href: `/user-guide`,
|
||||
badge: {
|
||||
variant: "neutral",
|
||||
children: "v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
props: {
|
||||
label: "Store API",
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
href: `/api/store`,
|
||||
href: `/v2/api/store`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -133,7 +104,7 @@ export const navbarItemsV2: NavbarItem[] = [
|
||||
label: "Admin API",
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
href: `/api/admin`,
|
||||
href: `/v2/api/admin`,
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -145,6 +116,22 @@ export const navbarItemsV2: NavbarItem[] = [
|
||||
href: `/ui`,
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "divider",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
props: {
|
||||
label: "Medusa V1",
|
||||
target: "_blank",
|
||||
rel: "noreferrer",
|
||||
href: `/`,
|
||||
badge: {
|
||||
variant: "neutral",
|
||||
children: "v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
export const legacyNavbarItems: NavbarItem[] = [
|
||||
@@ -236,7 +223,7 @@ export const mobileSidebarItemsV1: SidebarItemType[] = [
|
||||
isPathHref: true,
|
||||
},
|
||||
{
|
||||
title: "Book",
|
||||
title: "Learn Medusa V2",
|
||||
path: `/v2`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
@@ -246,7 +233,7 @@ export const mobileSidebarItemsV1: SidebarItemType[] = [
|
||||
|
||||
export const mobileSidebarItemsV2: SidebarItemType[] = [
|
||||
{
|
||||
title: "Book",
|
||||
title: "Docs",
|
||||
path: `/v2`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
@@ -257,29 +244,15 @@ export const mobileSidebarItemsV2: SidebarItemType[] = [
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
},
|
||||
{
|
||||
title: "Docs",
|
||||
path: `/`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
additionalElms: <Badge variant="neutral">v1</Badge>,
|
||||
},
|
||||
{
|
||||
title: "User Guide",
|
||||
path: `/user-guide`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
additionalElms: <Badge variant="neutral">v1</Badge>,
|
||||
},
|
||||
{
|
||||
title: "Store API",
|
||||
path: `/api/store`,
|
||||
path: `/v2/api/store`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
},
|
||||
{
|
||||
title: "Admin API",
|
||||
path: `/api/admin`,
|
||||
path: `/v2/api/admin`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
},
|
||||
@@ -289,6 +262,13 @@ export const mobileSidebarItemsV2: SidebarItemType[] = [
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
},
|
||||
{
|
||||
title: "Docs",
|
||||
path: `/`,
|
||||
loaded: true,
|
||||
isPathHref: true,
|
||||
additionalElms: <Badge variant="neutral">v1</Badge>,
|
||||
},
|
||||
]
|
||||
|
||||
export const legacyMobileSidebarItems: SidebarItemType[] = [
|
||||
@@ -327,13 +307,21 @@ export const legacyMobileSidebarItems: SidebarItemType[] = [
|
||||
export const searchFiltersV2: OptionType[] = [
|
||||
{
|
||||
value: "book",
|
||||
label: "Book",
|
||||
label: "Docs V2",
|
||||
},
|
||||
{
|
||||
value: "resources",
|
||||
label: "Resources",
|
||||
label: "Learning Resources",
|
||||
},
|
||||
// TODO add more filters once V2 become the main docs
|
||||
{
|
||||
value: "admin-v2",
|
||||
label: "Admin API",
|
||||
},
|
||||
{
|
||||
value: "store-v2",
|
||||
label: "Store API",
|
||||
},
|
||||
// TODO add more filters
|
||||
]
|
||||
|
||||
export const searchFiltersV1: OptionType[] = [
|
||||
|
||||
@@ -9,9 +9,14 @@ type Options = {
|
||||
export function getNavbarItems({
|
||||
basePath,
|
||||
activePath,
|
||||
version = "legacy"
|
||||
version = "legacy",
|
||||
}: Options): NavbarItem[] {
|
||||
const navbarItems = version === "v2" ? navbarItemsV2 : version === "v1" ? navbarItemsV1 : legacyNavbarItems
|
||||
const navbarItems =
|
||||
version === "v2"
|
||||
? navbarItemsV2
|
||||
: version === "v1"
|
||||
? navbarItemsV1
|
||||
: legacyNavbarItems
|
||||
return navbarItems.map((item) => {
|
||||
if (item.type === "divider") {
|
||||
return item
|
||||
@@ -23,7 +28,7 @@ export function getNavbarItems({
|
||||
...item.props,
|
||||
isActive: activePath === item.props?.href,
|
||||
href: `${basePath}${item.props?.href}`,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user