docs: restructure api-reference to allow base path (#7954)
This commit is contained in:
@@ -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 (
|
||||
<AreaProvider area={"admin"}>
|
||||
<PageTitleProvider>
|
||||
<h1 className="!text-h2 block lg:hidden">
|
||||
Medusa V2 Admin API Reference
|
||||
</h1>
|
||||
<DividedLayout
|
||||
mainContent={
|
||||
<Section>
|
||||
<h1 className="!text-h2 hidden lg:block">
|
||||
Medusa V2 Admin API Reference
|
||||
</h1>
|
||||
<AdminContentV2 />
|
||||
</Section>
|
||||
}
|
||||
codeContent={<ClientLibrariesV2 />}
|
||||
className="flex-col-reverse"
|
||||
/>
|
||||
<Tags />
|
||||
</PageTitleProvider>
|
||||
</AreaProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -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() {
|
||||
+2
-2
@@ -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)
|
||||
+2
-2
@@ -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"
|
||||
|
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 253 KiB |
@@ -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 (
|
||||
<AreaProvider area={"store"}>
|
||||
<PageTitleProvider>
|
||||
<h1 className="!text-h2 block lg:hidden">
|
||||
Medusa V2 Store API Reference
|
||||
</h1>
|
||||
<DividedLayout
|
||||
mainContent={
|
||||
<Section>
|
||||
<h1 className="!text-h2 hidden lg:block">
|
||||
Medusa V2 Store API Reference
|
||||
</h1>
|
||||
<StoreContentV2 />
|
||||
</Section>
|
||||
}
|
||||
codeContent={<ClientLibrariesV2 />}
|
||||
className="flex-col-reverse"
|
||||
/>
|
||||
<Tags />
|
||||
</PageTitleProvider>
|
||||
</AreaProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 253 KiB After Width: | Height: | Size: 253 KiB |
@@ -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 (
|
||||
<AreaProvider area={area}>
|
||||
<PageTitleProvider>
|
||||
<h1 className="!text-h2 block lg:hidden">
|
||||
Medusa V2 {capitalize(area)} API Reference
|
||||
</h1>
|
||||
<DividedLayout
|
||||
mainContent={
|
||||
<Section>
|
||||
<h1 className="!text-h2 hidden lg:block">
|
||||
Medusa V2 {capitalize(area)} API Reference
|
||||
</h1>
|
||||
{area.includes("admin") && <AdminContentV2 />}
|
||||
{area.includes("store") && <StoreContentV2 />}
|
||||
</Section>
|
||||
}
|
||||
codeContent={<ClientLibrariesV2 />}
|
||||
className="flex-col-reverse"
|
||||
/>
|
||||
<Tags />
|
||||
</PageTitleProvider>
|
||||
</AreaProvider>
|
||||
)
|
||||
}
|
||||
|
||||
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",
|
||||
},
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user