diff --git a/www/apps/api-reference/app/admin/page.tsx b/www/apps/api-reference/app/admin/page.tsx new file mode 100644 index 0000000000..700c2a512d --- /dev/null +++ b/www/apps/api-reference/app/admin/page.tsx @@ -0,0 +1,42 @@ +import AreaProvider from "@/providers/area" +import AdminContentV2 from "../_mdx/admin.mdx" +import ClientLibrariesV2 from "../_mdx/client-libraries.mdx" +import Section from "@/components/Section" +import Tags from "@/components/Tags" +import DividedLayout from "@/layouts/Divided" +import PageTitleProvider from "@/providers/page-title" + +const ReferencePage = async () => { + return ( + + +

+ Medusa V2 Admin API Reference +

+ +

+ Medusa V2 Admin API Reference +

+ + + } + codeContent={} + className="flex-col-reverse" + /> + +
+
+ ) +} + +export default ReferencePage + +export function generateMetadata() { + return { + title: `Medusa Admin API Reference`, + description: `REST API reference for the Medusa admin API. This reference includes code snippets and examples for Medusa JS Client and cURL.`, + metadataBase: process.env.NEXT_PUBLIC_BASE_URL, + } +} diff --git a/www/apps/api-reference/app/v2/api/algolia/route.ts b/www/apps/api-reference/app/api/algolia/route.ts similarity index 94% rename from www/apps/api-reference/app/v2/api/algolia/route.ts rename to www/apps/api-reference/app/api/algolia/route.ts index daf911b755..c4897c6266 100644 --- a/www/apps/api-reference/app/v2/api/algolia/route.ts +++ b/www/apps/api-reference/app/api/algolia/route.ts @@ -1,12 +1,12 @@ import OpenAPIParser from "@readme/openapi-parser" import algoliasearch from "algoliasearch" -import type { ExpandedDocument, Operation } from "../../../../types/openapi" +import type { ExpandedDocument, Operation } from "../../../types/openapi" import path from "path" -import getPathsOfTag from "../../../../utils/get-paths-of-tag" -import getSectionId from "../../../../utils/get-section-id" +import getPathsOfTag from "../../../utils/get-paths-of-tag" +import getSectionId from "../../../utils/get-section-id" import { NextResponse } from "next/server" import { JSDOM } from "jsdom" -import getUrl from "../../../../utils/get-url" +import getUrl from "../../../utils/get-url" import { capitalize } from "docs-ui" export async function GET() { diff --git a/www/apps/api-reference/app/v2/api/base-specs/route.ts b/www/apps/api-reference/app/api/base-specs/route.ts similarity index 100% rename from www/apps/api-reference/app/v2/api/base-specs/route.ts rename to www/apps/api-reference/app/api/base-specs/route.ts diff --git a/www/apps/api-reference/app/v2/api/download/[area]/route.ts b/www/apps/api-reference/app/api/download/[area]/route.ts similarity index 100% rename from www/apps/api-reference/app/v2/api/download/[area]/route.ts rename to www/apps/api-reference/app/api/download/[area]/route.ts diff --git a/www/apps/api-reference/app/v2/api/schema/route.ts b/www/apps/api-reference/app/api/schema/route.ts similarity index 93% rename from www/apps/api-reference/app/v2/api/schema/route.ts rename to www/apps/api-reference/app/api/schema/route.ts index bbe840751d..fb0ec3448a 100644 --- a/www/apps/api-reference/app/v2/api/schema/route.ts +++ b/www/apps/api-reference/app/api/schema/route.ts @@ -1,9 +1,9 @@ import { NextResponse } from "next/server" -import { SchemaObject } from "../../../../types/openapi" +import { SchemaObject } from "../../../types/openapi" import path from "path" import { existsSync, promises as fs } from "fs" import { parseDocument } from "yaml" -import dereference from "../../../../utils/dereference" +import dereference from "../../../utils/dereference" export async function GET(request: Request) { const { searchParams } = new URL(request.url) diff --git a/www/apps/api-reference/app/v2/api/tag/route.ts b/www/apps/api-reference/app/api/tag/route.ts similarity index 100% rename from www/apps/api-reference/app/v2/api/tag/route.ts rename to www/apps/api-reference/app/api/tag/route.ts diff --git a/www/apps/api-reference/app/v2/api/[area]/layout.tsx b/www/apps/api-reference/app/layout.tsx similarity index 90% rename from www/apps/api-reference/app/v2/api/[area]/layout.tsx rename to www/apps/api-reference/app/layout.tsx index 7bfc724ddf..3994c92fbb 100644 --- a/www/apps/api-reference/app/v2/api/[area]/layout.tsx +++ b/www/apps/api-reference/app/layout.tsx @@ -1,6 +1,6 @@ -import "../../../globals.css" +import "./globals.css" import Navbar from "@/components/Navbar" -import Providers from "../../../../providers" +import Providers from "../providers" import { WideLayout } from "docs-ui" import { Inter, Roboto_Mono } from "next/font/google" import clsx from "clsx" diff --git a/www/apps/api-reference/app/v2/api/[area]/opengraph-image.jpg b/www/apps/api-reference/app/opengraph-image.jpg similarity index 100% rename from www/apps/api-reference/app/v2/api/[area]/opengraph-image.jpg rename to www/apps/api-reference/app/opengraph-image.jpg diff --git a/www/apps/api-reference/app/store/page.tsx b/www/apps/api-reference/app/store/page.tsx new file mode 100644 index 0000000000..367744b971 --- /dev/null +++ b/www/apps/api-reference/app/store/page.tsx @@ -0,0 +1,42 @@ +import AreaProvider from "@/providers/area" +import StoreContentV2 from "../_mdx/store.mdx" +import ClientLibrariesV2 from "../_mdx/client-libraries.mdx" +import Section from "@/components/Section" +import Tags from "@/components/Tags" +import DividedLayout from "@/layouts/Divided" +import PageTitleProvider from "@/providers/page-title" + +const ReferencePage = async () => { + return ( + + +

+ Medusa V2 Store API Reference +

+ +

+ Medusa V2 Store API Reference +

+ + + } + codeContent={} + className="flex-col-reverse" + /> + +
+
+ ) +} + +export default ReferencePage + +export function generateMetadata() { + return { + title: `Medusa Store API Reference`, + description: `REST API reference for the Medusa store API. This reference includes code snippets and examples for Medusa JS Client and cURL.`, + metadataBase: process.env.NEXT_PUBLIC_BASE_URL, + } +} diff --git a/www/apps/api-reference/app/v2/api/[area]/twitter-image.jpg b/www/apps/api-reference/app/twitter-image.jpg similarity index 100% rename from www/apps/api-reference/app/v2/api/[area]/twitter-image.jpg rename to www/apps/api-reference/app/twitter-image.jpg diff --git a/www/apps/api-reference/app/v2/api/[area]/page.tsx b/www/apps/api-reference/app/v2/api/[area]/page.tsx deleted file mode 100644 index 53fb266157..0000000000 --- a/www/apps/api-reference/app/v2/api/[area]/page.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import AreaProvider from "@/providers/area" -import AdminContentV2 from "../../../_mdx/admin.mdx" -import StoreContentV2 from "../../../_mdx/store.mdx" -import ClientLibrariesV2 from "../../../_mdx/client-libraries.mdx" -import Section from "@/components/Section" -import Tags from "@/components/Tags" -import type { Area } from "@/types/openapi" -import DividedLayout from "@/layouts/Divided" -import { capitalize } from "docs-ui" -import PageTitleProvider from "@/providers/page-title" - -type ReferencePageProps = { - params: { - area: Area - } -} - -const ReferencePage = async ({ params: { area } }: ReferencePageProps) => { - return ( - - -

- Medusa V2 {capitalize(area)} API Reference -

- -

- Medusa V2 {capitalize(area)} API Reference -

- {area.includes("admin") && } - {area.includes("store") && } - - } - codeContent={} - className="flex-col-reverse" - /> - -
-
- ) -} - -export default ReferencePage - -export function generateMetadata({ params: { area } }: ReferencePageProps) { - return { - title: `Medusa ${capitalize(area)} API Reference`, - description: `REST API reference for the Medusa ${area} API. This reference includes code snippets and examples for Medusa JS Client and cURL.`, - metadataBase: process.env.NEXT_PUBLIC_BASE_URL, - } -} - -export const dynamicParams = false - -export async function generateStaticParams() { - return [ - { - area: "admin", - }, - { - area: "store", - }, - ] -} diff --git a/www/apps/api-reference/components/Navbar/index.tsx b/www/apps/api-reference/components/Navbar/index.tsx index d98b3ca6b8..ec4d881eb3 100644 --- a/www/apps/api-reference/components/Navbar/index.tsx +++ b/www/apps/api-reference/components/Navbar/index.tsx @@ -22,7 +22,7 @@ const Navbar = () => { () => getNavbarItems({ basePath: config.baseUrl, - activePath: pathname, + activePath: basePathUrl(pathname), version: "v2", }), [pathname] @@ -31,8 +31,8 @@ const Navbar = () => { return ( { paths: PathsObject }>( !Object.keys(paths).length - ? basePathUrl(`/tag?tagName=${tagSlugName}&area=${area}`) + ? basePathUrl(`/api/tag?tagName=${tagSlugName}&area=${area}`) : null, swrFetcher, { diff --git a/www/apps/api-reference/components/Tags/Section/index.tsx b/www/apps/api-reference/components/Tags/Section/index.tsx index 97ad4a651d..e11d160efc 100644 --- a/www/apps/api-reference/components/Tags/Section/index.tsx +++ b/www/apps/api-reference/components/Tags/Section/index.tsx @@ -58,7 +58,7 @@ const TagSection = ({ tag }: TagSectionProps) => { }>( tag["x-associatedSchema"] ? basePathUrl( - `/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}` + `/api/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}` ) : null, swrFetcher, diff --git a/www/apps/api-reference/components/Tags/index.tsx b/www/apps/api-reference/components/Tags/index.tsx index fc3d1fd026..d558fe8bc6 100644 --- a/www/apps/api-reference/components/Tags/index.tsx +++ b/www/apps/api-reference/components/Tags/index.tsx @@ -36,7 +36,7 @@ const Tags = () => { const { data } = useSWR( loadData && !baseSpecs - ? basePathUrl(`/base-specs?area=${area}&expand=${expand}`) + ? basePathUrl(`/api/base-specs?area=${area}&expand=${expand}`) : null, swrFetcher, { diff --git a/www/apps/api-reference/next.config.mjs b/www/apps/api-reference/next.config.mjs index 6ef9302fa2..c9399ad994 100644 --- a/www/apps/api-reference/next.config.mjs +++ b/www/apps/api-reference/next.config.mjs @@ -3,7 +3,7 @@ import bundleAnalyzer from "@next/bundle-analyzer" /** @type {import('next').NextConfig} */ const nextConfig = { - // basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2", + basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2/api", async rewrites() { return { fallback: [