docs: fix expand badge (#8611)

* fix component

* update expand URL
This commit is contained in:
Shahed Nasser
2024-08-16 09:26:16 +03:00
committed by GitHub
parent 47eb19ca5d
commit 5abe9f9c66
4 changed files with 11 additions and 9 deletions
@@ -2,7 +2,7 @@ import React from "react"
import { Badge, Link, Tooltip } from "@/components" import { Badge, Link, Tooltip } from "@/components"
export type ExpandableNoticeProps = { export type ExpandableNoticeProps = {
type: "request" | "method" type: "request" | "method" | "workflow"
link: string link: string
badgeContent?: React.ReactNode badgeContent?: React.ReactNode
badgeClassName?: string badgeClassName?: string
@@ -19,8 +19,8 @@ export const ExpandableNotice = ({
tooltipChildren={ tooltipChildren={
<> <>
If this {type} accepts an <code>expand</code>{" "} If this {type} accepts an <code>expand</code>{" "}
{type === "request" ? "parameter" : "property or option"}, {type === "request" ? "parameter" : "parameter or property"},
<br /> this field can be <Link href={link}>expanded</Link> into an <br /> this relation can be <Link href={link}>expanded</Link> into an
object. object.
</> </>
} }
@@ -25,6 +25,7 @@ import { useIsBrowser, useSiteConfig } from "../../.."
type CommonProps = ParentCommonProps & { type CommonProps = ParentCommonProps & {
level?: number level?: number
referenceType?: "method" | "workflow"
} }
type TypeListItemProps = { type TypeListItemProps = {
@@ -39,6 +40,7 @@ const TypeListItem = ({
expandUrl, expandUrl,
elementKey, elementKey,
sectionTitle, sectionTitle,
referenceType = "method",
}: TypeListItemProps) => { }: TypeListItemProps) => {
const isBrowser = useIsBrowser() const isBrowser = useIsBrowser()
const pathname = usePathname() const pathname = usePathname()
@@ -227,9 +229,9 @@ const TypeListItem = ({
)} )}
{item.expandable && ( {item.expandable && (
<ExpandableNotice <ExpandableNotice
type="method" type={referenceType}
link={expandUrl || "#"} link={expandUrl || "#"}
badgeClassName="!p-0 leading-none" badgeClassName="!p-docs_0.25 block leading-none"
badgeContent={<ArrowsPointingOutMini />} badgeContent={<ArrowsPointingOutMini />}
/> />
)} )}
@@ -3,10 +3,6 @@ import { FormattingOptionsType } from "types"
const medusaOptions: FormattingOptionsType = { const medusaOptions: FormattingOptionsType = {
"^medusa/": { "^medusa/": {
maxLevel: 2, maxLevel: 2,
parameterComponentExtraProps: {
expandUrl:
"https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records",
},
}, },
"^medusa/classes/medusa\\.(Store*|Admin*)": { "^medusa/classes/medusa\\.(Store*|Admin*)": {
reflectionGroups: { reflectionGroups: {
@@ -50,6 +50,10 @@ const mergerOptions: Partial<TypeDocOptions> = {
parameterStyle: "component", parameterStyle: "component",
parameterComponent: "TypeList", parameterComponent: "TypeList",
mdxImports: [`import { TypeList } from "docs-ui"`], mdxImports: [`import { TypeList } from "docs-ui"`],
parameterComponentExtraProps: {
expandUrl:
"https://docs.medusajs.com/v2/advanced-development/data-models/manage-relationships#retrieve-records-of-relation",
},
}, },
internal: { internal: {
maxLevel: 1, maxLevel: 1,