docs(ui,docs): added upgrade guides link to UI docs (#5240)
* added medusa ui index page * remove console
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
sidebar_custom_props:
|
||||||
|
exclude_from_auto_sidebar: true
|
||||||
|
exclude_from_doc_list: true
|
||||||
|
---
|
||||||
|
|
||||||
|
import DocCardList from '@theme/DocCardList';
|
||||||
|
|
||||||
|
# Medusa UI Upgrade Guides
|
||||||
|
|
||||||
|
<DocCardList colSize={6} />
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
require("dotenv").config()
|
require("dotenv").config()
|
||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const reverseSidebar = require("./src/utils/reverseSidebar")
|
const reverseSidebar = require("./src/utils/reverse-sidebar")
|
||||||
|
const excludeSidebarResults = require("./src/utils/exclude-sidebar-results")
|
||||||
|
|
||||||
const announcementBar = JSON.parse(fs.readFileSync("./announcement.json"))
|
const announcementBar = JSON.parse(fs.readFileSync("./announcement.json"))
|
||||||
|
|
||||||
@@ -251,7 +252,10 @@ const config = {
|
|||||||
...args
|
...args
|
||||||
}) {
|
}) {
|
||||||
const sidebarItems = await defaultSidebarItemsGenerator(args)
|
const sidebarItems = await defaultSidebarItemsGenerator(args)
|
||||||
return reverseSidebar(sidebarItems, args.item)
|
return reverseSidebar(
|
||||||
|
excludeSidebarResults(sidebarItems, args.item),
|
||||||
|
args.item
|
||||||
|
)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
theme: {
|
theme: {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ module.exports = {
|
|||||||
label: "Ecommerce",
|
label: "Ecommerce",
|
||||||
customProps: {
|
customProps: {
|
||||||
iconName: "shopping-cart",
|
iconName: "shopping-cart",
|
||||||
excludeFromDocList: true,
|
exclude_from_doc_list: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1951,6 +1951,10 @@ module.exports = {
|
|||||||
customProps: {
|
customProps: {
|
||||||
sidebar_is_group_headline: true,
|
sidebar_is_group_headline: true,
|
||||||
},
|
},
|
||||||
|
link: {
|
||||||
|
type: "doc",
|
||||||
|
id: "upgrade-guides/medusa-ui/index",
|
||||||
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: "autogenerated",
|
type: "autogenerated",
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ import {
|
|||||||
import DocCard from "@theme/DocCard"
|
import DocCard from "@theme/DocCard"
|
||||||
import type { Props } from "@theme/DocCardList"
|
import type { Props } from "@theme/DocCardList"
|
||||||
|
|
||||||
function DocCardListForCurrentSidebarCategory({ className }: Props) {
|
function DocCardListForCurrentSidebarCategory({
|
||||||
|
className,
|
||||||
|
...rest
|
||||||
|
}: ModifiedProps) {
|
||||||
const category = useCurrentSidebarCategory()
|
const category = useCurrentSidebarCategory()
|
||||||
return <DocCardList items={category.items} className={className} />
|
return <DocCardList className={className} {...rest} items={category.items} />
|
||||||
}
|
}
|
||||||
|
|
||||||
type ModifiedProps = {
|
type ModifiedProps = {
|
||||||
@@ -22,7 +25,7 @@ export default function DocCardList(props: ModifiedProps): JSX.Element {
|
|||||||
return <DocCardListForCurrentSidebarCategory {...props} />
|
return <DocCardListForCurrentSidebarCategory {...props} />
|
||||||
}
|
}
|
||||||
const filteredItems = filterDocCardListItems(items).filter(
|
const filteredItems = filterDocCardListItems(items).filter(
|
||||||
(item) => !item.customProps.excludeFromDocList
|
(item) => !item.customProps?.exclude_from_doclist
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
function excludeSidebarResults(sidebarItems, categoryItem) {
|
||||||
|
const results = []
|
||||||
|
sidebarItems.forEach((item) => {
|
||||||
|
if (item.type === "category") {
|
||||||
|
results.push({
|
||||||
|
...item,
|
||||||
|
items: excludeSidebarResults(item.items, categoryItem),
|
||||||
|
})
|
||||||
|
} else if (!item.customProps?.exclude_from_auto_sidebar) {
|
||||||
|
return results.push(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = excludeSidebarResults
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ArrowUpRightOnBox } from "@medusajs/icons"
|
||||||
import { NavbarLinkProps, SidebarSectionItemsType } from "docs-ui"
|
import { NavbarLinkProps, SidebarSectionItemsType } from "docs-ui"
|
||||||
|
|
||||||
type DocsConfig = {
|
type DocsConfig = {
|
||||||
@@ -65,6 +66,16 @@ export const docsConfig: DocsConfig = {
|
|||||||
path: "/installation/standalone-project",
|
path: "/installation/standalone-project",
|
||||||
isPathHref: true,
|
isPathHref: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "Upgrade Guides",
|
||||||
|
path: `${process.env.NEXT_PUBLIC_DOCS_URL}/upgrade-guides/medusa-ui`,
|
||||||
|
isPathHref: true,
|
||||||
|
additionalElms: <ArrowUpRightOnBox />,
|
||||||
|
linkProps: {
|
||||||
|
target: "_blank",
|
||||||
|
rel: "noreferrer",
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -94,6 +94,7 @@ export const SidebarItem = ({
|
|||||||
}}
|
}}
|
||||||
replace
|
replace
|
||||||
shallow
|
shallow
|
||||||
|
{...item.linkProps}
|
||||||
>
|
>
|
||||||
<span>{item.title}</span>
|
<span>{item.title}</span>
|
||||||
{item.additionalElms}
|
{item.additionalElms}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export type SidebarItemType = {
|
|||||||
children?: SidebarItemType[]
|
children?: SidebarItemType[]
|
||||||
loaded?: boolean
|
loaded?: boolean
|
||||||
isPathHref?: boolean
|
isPathHref?: boolean
|
||||||
|
linkProps?: React.AllHTMLAttributes<HTMLAnchorElement>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SidebarSectionItemsType = {
|
export type SidebarSectionItemsType = {
|
||||||
|
|||||||
Reference in New Issue
Block a user