Skip to content

Commit

Permalink
docs: fix download button + other fixes (#8032)
Browse files Browse the repository at this point in the history
- Fix text of download button
- Small fix to styling on small devies
- Fix mobile sidebar items using incorrect base url
  • Loading branch information
shahednasser authored Jul 9, 2024
1 parent b6fd82e commit 4c89f91
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 46 deletions.
6 changes: 5 additions & 1 deletion www/apps/api-reference/app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const ReferencePage = async () => {
<AdminContentV2 />
</Section>
}
codeContent={<ClientLibrariesV2 />}
codeContent={
<div className="mb-1 lg:mb-0">
<ClientLibrariesV2 />
</div>
}
className="flex-col-reverse"
/>
<Tags />
Expand Down
6 changes: 5 additions & 1 deletion www/apps/api-reference/app/store/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ const ReferencePage = async () => {
<StoreContentV2 />
</Section>
}
codeContent={<ClientLibrariesV2 />}
codeContent={
<div className="mb-1 lg:mb-0">
<ClientLibrariesV2 />
</div>
}
className="flex-col-reverse"
/>
<Tags />
Expand Down
2 changes: 1 addition & 1 deletion www/apps/api-reference/components/DownloadFull/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DownloadFull = () => {
download
target="_blank"
>
Download openapi.yaml
Download OpenApi Specs Collection
</Link>
</Button>
)
Expand Down
11 changes: 8 additions & 3 deletions www/apps/api-reference/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { DocsConfig } from "types"
import { mobileSidebarItemsV2 } from "docs-ui"
import { getMobileSidebarItems } from "docs-ui"

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"

export const config: DocsConfig = {
baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000",
baseUrl,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
// sidebar is auto generated
sidebar: {
Expand All @@ -14,6 +16,9 @@ export const config: DocsConfig = {
},
],
bottom: [],
mobile: mobileSidebarItemsV2,
mobile: getMobileSidebarItems({
baseUrl,
version: "v2",
}),
},
}
2 changes: 1 addition & 1 deletion www/apps/book/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const Navbar = () => {
() =>
getNavbarItems({
basePath: config.baseUrl,
activePath: basePathUrl(""),
activePath: basePathUrl(),
version: "v2",
}),
[]
Expand Down
6 changes: 4 additions & 2 deletions www/apps/book/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { DocsConfig } from "types"
import { sidebarConfig } from "./sidebar"

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"

export const config: DocsConfig = {
titleSuffix: "Medusa v2 Docs",
baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000",
baseUrl,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
sidebar: sidebarConfig,
sidebar: sidebarConfig(baseUrl),
}
15 changes: 10 additions & 5 deletions www/apps/book/config/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Badge, mobileSidebarItemsV2 } from "docs-ui"
import { Badge, getMobileSidebarItems } from "docs-ui"
import type { SidebarConfig, SidebarItemType } from "@/types"
import { sidebar } from "../sidebar.mjs"

Expand All @@ -17,8 +17,13 @@ const normalizeSidebarItems = (items: SidebarItemType[]) =>
return item
})

export const sidebarConfig: SidebarConfig = {
top: normalizeSidebarItems(sidebar),
bottom: [],
mobile: mobileSidebarItemsV2,
export const sidebarConfig = (baseUrl: string): SidebarConfig => {
return {
top: normalizeSidebarItems(sidebar),
bottom: [],
mobile: getMobileSidebarItems({
baseUrl,
version: "v2",
}),
}
}
11 changes: 8 additions & 3 deletions www/apps/resources/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { DocsConfig } from "types"
import { mobileSidebarItemsV2 } from "docs-ui"
import { getMobileSidebarItems } from "docs-ui"
import { generatedSidebar } from "../generated/sidebar.mjs"

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"

export const config: DocsConfig = {
titleSuffix: "Medusa Learning Resources",
baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000",
baseUrl,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
sidebar: {
top: generatedSidebar,
bottom: [],
mobile: mobileSidebarItemsV2,
mobile: getMobileSidebarItems({
baseUrl,
version: "v2",
}),
},
}
7 changes: 5 additions & 2 deletions www/apps/ui/src/config/docs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArrowUpRightOnBox } from "@medusajs/icons"
import { NavbarItem, getNavbarItems, mobileSidebarItemsV1 } from "docs-ui"
import { NavbarItem, getMobileSidebarItems, getNavbarItems } from "docs-ui"
import { SidebarSectionItemsType } from "types"
import { siteConfig } from "./site"

Expand Down Expand Up @@ -280,6 +280,9 @@ export const docsConfig: DocsConfig = {
],
},
],
mobile: mobileSidebarItemsV1,
mobile: getMobileSidebarItems({
baseUrl: siteConfig.baseUrl,
version: "v1",
}),
},
}
11 changes: 8 additions & 3 deletions www/apps/user-guide/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { DocsConfig } from "types"
import { mobileSidebarItemsV2 } from "docs-ui"
import { getMobileSidebarItems } from "docs-ui"
import { generatedSidebar as sidebar } from "@/generated/sidebar.mjs"

const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000"

export const config: DocsConfig = {
titleSuffix: "Medusa Admin User Guide",
baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000",
baseUrl,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
sidebar: {
top: sidebar,
bottom: [],
mobile: mobileSidebarItemsV2,
mobile: getMobileSidebarItems({
baseUrl,
version: "v2",
}),
},
}
47 changes: 23 additions & 24 deletions www/packages/docs-ui/src/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,22 @@ export const navbarItemsV1: NavbarItem[] = [
href: `/ui`,
},
},
// TODO enable them later
// {
// type: "divider",
// },
// {
// type: "link",
// props: {
// label: "Learn Medusa v2",
// target: "_blank",
// rel: "noreferrer",
// href: `/v2`,
// badge: {
// variant: "blue",
// children: "New",
// },
// },
// },
{
type: "divider",
},
{
type: "link",
props: {
label: "Learn Medusa v2",
target: "_blank",
rel: "noreferrer",
href: `/v2`,
badge: {
variant: "blue",
children: "New",
},
},
},
]

export const navbarItemsV2: NavbarItem[] = [
Expand Down Expand Up @@ -162,13 +161,13 @@ export const mobileSidebarItemsV1: SidebarItemType[] = [
loaded: true,
isPathHref: true,
},
// {
// title: "Learn Medusa V2",
// path: `/v2`,
// loaded: true,
// isPathHref: true,
// additionalElms: <Badge variant="blue">v2</Badge>,
// },
{
title: "Learn Medusa V2",
path: `/v2`,
loaded: true,
isPathHref: true,
additionalElms: <Badge variant="blue">v2</Badge>,
},
]

export const mobileSidebarItemsV2: SidebarItemType[] = [
Expand Down
21 changes: 21 additions & 0 deletions www/packages/docs-ui/src/utils/get-mobile-sidebar-items.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { SidebarItemType } from "types"
import { mobileSidebarItemsV1, mobileSidebarItemsV2 } from ".."

type Options = {
baseUrl: string
version?: "v1" | "v2"
}

export function getMobileSidebarItems({
baseUrl,
version = "v1",
}: Options): SidebarItemType[] {
const mobileItems =
version === "v2" ? mobileSidebarItemsV2 : mobileSidebarItemsV1
return mobileItems.map((item) => {
return {
...item,
path: `${baseUrl}${item.path}`,
}
})
}
1 change: 1 addition & 0 deletions www/packages/docs-ui/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export * from "./decode-str"
export * from "./dom-utils"
export * from "./format-report-link"
export * from "./get-link-with-base-path"
export * from "./get-mobile-sidebar-items"
export * from "./get-navbar-items"
export * from "./get-os-shortcut"
export * from "./get-scrolled-top"
Expand Down

0 comments on commit 4c89f91

Please sign in to comment.