Skip to content

Commit

Permalink
docs(v1.x): update configuration to add /v1 path prefix (#9731)
Browse files Browse the repository at this point in the history
* docs(v1.x): update configuration to add /v1 path prefix

* fix build error

* add trailing slash

* force docusaurus version

* update yarn lock

* updated docusaurus to latest version

* change build script

* added build:prod turbo command

* fix turbo script

* remove redirect
  • Loading branch information
shahednasser authored Oct 24, 2024
1 parent 778cb15 commit 9a4e805
Show file tree
Hide file tree
Showing 266 changed files with 2,973 additions and 1,375 deletions.
6 changes: 3 additions & 3 deletions www/apps/api-reference/app/_mdx/admin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ All API Routes are prefixed with `/admin`. So, during development, the API Route

There are different ways you can send requests to these API Routes, including:

- Using Medusa's [JavaScript Client](https://docs.medusajs.com/js-client/overview)
- Using the [Medusa React](https://docs.medusajs.com/medusa-react/overview) library
- Using Medusa's [JavaScript Client](https://docs.medusajs.com/v1/js-client/overview)
- Using the [Medusa React](https://docs.medusajs.com/v1/medusa-react/overview) library
- Using cURL

Aside from this API reference, check out the [Commerce Modules](https://docs.medusajs.com/modules/overview) section of the documentation for guides on how to use these APIs in different scenarios.
Aside from this API reference, check out the [Commerce Modules](https://docs.medusajs.com/v1/modules/overview) section of the documentation for guides on how to use these APIs in different scenarios.

<Feedback
event="survey_api-ref"
Expand Down
2 changes: 1 addition & 1 deletion www/apps/api-reference/app/_mdx/client-libraries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import DownloadFull from "@/components/DownloadFull"

### Just Getting Started?

Check out the [quickstart guide](https://docs.medusajs.com/create-medusa-app).
Check out the [quickstart guide](https://docs.medusajs.com/v1/create-medusa-app).

<Space bottom={8} />

Expand Down
12 changes: 6 additions & 6 deletions www/apps/api-reference/app/_mdx/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ All API Routes are prefixed with `/store`. So, during development, the API Route

There are different ways you can send requests to these API Routes, including:

- Using Medusa's [JavaScript Client](https://docs.medusajs.com/js-client/overview)
- Using the [Medusa React](https://docs.medusajs.com/medusa-react/overview) library
- Using Medusa's [JavaScript Client](https://docs.medusajs.com/v1/js-client/overview)
- Using the [Medusa React](https://docs.medusajs.com/v1/medusa-react/overview) library
- Using cURL

Aside from this API reference, check out the [Commerce Modules](https://docs.medusajs.com/modules/overview) section of the documentation for guides on how to use these APIs in different scenarios.
Aside from this API reference, check out the [Commerce Modules](https://docs.medusajs.com/v1/modules/overview) section of the documentation for guides on how to use these APIs in different scenarios.

<Feedback
event="survey_api-ref"
Expand Down Expand Up @@ -150,12 +150,12 @@ request based on the publishable API key. At the moment, publishable API keys on
It's highly recommended to create a publishable API key and pass it in the header of all your requests to the
store APIs.

You can learn more about publishable API keys and how to use them in [this documentation](https://docs.medusajs.com/development/publishable-api-keys/).
You can learn more about publishable API keys and how to use them in [this documentation](https://docs.medusajs.com/v1/development/publishable-api-keys/).

### How to Create a Publishable API Key

You can create a publishable API key either using the [admin REST APIs](https://docs.medusajs.com/development/publishable-api-keys/admin/manage-publishable-api-keys),
or using the [Medusa Admin](https://docs.medusajs.com/user-guide/settings/publishable-api-keys).
You can create a publishable API key either using the [admin REST APIs](https://docs.medusajs.com/v1/development/publishable-api-keys/admin/manage-publishable-api-keys),
or using the [Medusa Admin](https://docs.medusajs.com/v1/user-guide/settings/publishable-api-keys).

### How to Use a Publishable API Key

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import AreaProvider from "@/providers/area"
import AdminDescription from "../../_mdx/admin.mdx"
import StoreDescription from "../../_mdx/store.mdx"
import ClientLibraries from "../../_mdx/client-libraries.mdx"
import AdminDescription from "../_mdx/admin.mdx"
import ClientLibraries 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"
import PageTitleProvider from "../../providers/page-title"

type ReferencePageProps = {
params: {
area: Area
}
}
const ReferencePage = async () => {
const area: Area = "admin"

const ReferencePage = async ({ params: { area } }: ReferencePageProps) => {
return (
<AreaProvider area={area}>
<PageTitleProvider>
Expand All @@ -28,8 +23,7 @@ const ReferencePage = async ({ params: { area } }: ReferencePageProps) => {
<h1 className="!text-h2 hidden lg:block">
Medusa V1 {capitalize(area)} API Reference
</h1>
{area.includes("admin") && <AdminDescription />}
{area.includes("store") && <StoreDescription />}
<AdminDescription />
</Section>
}
codeContent={<ClientLibraries />}
Expand All @@ -43,23 +37,12 @@ const ReferencePage = async ({ params: { area } }: ReferencePageProps) => {

export default ReferencePage

export function generateMetadata({ params: { area } }: ReferencePageProps) {
export function generateMetadata() {
const area: Area = "admin"

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",
},
]
}
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "../../globals.css"
import "./globals.css"
import Navbar from "@/components/Navbar"
import Providers from "../../../providers"
import { WideLayout } from "docs-ui"
import { Inter, Roboto_Mono } from "next/font/google"
import clsx from "clsx"
import Providers from "../providers"

export const metadata = {
title: "Medusa API Reference",
Expand Down
48 changes: 48 additions & 0 deletions www/apps/api-reference/app/store/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import AreaProvider from "@/providers/area"
import StoreDescription from "../_mdx/store.mdx"
import ClientLibraries 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"

const ReferencePage = async () => {
const area: Area = "store"

return (
<AreaProvider area={area}>
<PageTitleProvider>
<h1 className="!text-h2 block lg:hidden">
Medusa V1 {capitalize(area)} API Reference
</h1>
<DividedLayout
mainContent={
<Section>
<h1 className="!text-h2 hidden lg:block">
Medusa V1 {capitalize(area)} API Reference
</h1>
<StoreDescription />
</Section>
}
codeContent={<ClientLibraries />}
className="flex-col-reverse"
/>
<Tags />
</PageTitleProvider>
</AreaProvider>
)
}

export default ReferencePage

export function generateMetadata() {
const area: Area = "store"

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,
}
}
File renamed without changes.
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 @@ -9,7 +9,7 @@ const DownloadFull = () => {

return (
<Button variant="secondary">
<Link href={`/api/download/${area}`} download target="_blank">
<Link href={`/download/${area}`} download target="_blank">
Download openapi.yaml
</Link>
</Button>
Expand Down
5 changes: 3 additions & 2 deletions www/apps/api-reference/components/Navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useMemo } from "react"
import { config } from "../../config"
import { usePathname } from "next/navigation"
import VersionSwitcher from "../VersionSwitcher"
import { getBasePathUrl } from "../../utils/get-base-path-url"

const Navbar = () => {
const { setMobileSidebarOpen, mobileSidebarOpen } = useSidebar()
Expand All @@ -29,8 +30,8 @@ const Navbar = () => {
return (
<UiNavbar
logo={{
light: "/images/logo-icon.png",
dark: "/images/logo-icon-dark.png",
light: getBasePathUrl("/images/logo-icon.png"),
dark: getBasePathUrl("/images/logo-icon-dark.png"),
}}
items={navbarItems}
mobileMenuButton={{
Expand Down
19 changes: 6 additions & 13 deletions www/apps/api-reference/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,20 @@ import bundleAnalyzer from "@next/bundle-analyzer"

/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v1/api",
async rewrites() {
const rewriteFallbacks = [
{
source: "/ui",
destination: `${process.env.NEXT_PUBLIC_UI_URL}/ui`,
source: "/v1",
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/v1`,
},
{
source: "/ui/:path*",
destination: `${process.env.NEXT_PUBLIC_UI_URL}/ui/:path*`,
},
{
source: "/v2",
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2`,
},
{
source: "/v2/:path*",
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2/:path*`,
source: "/v1/:path*",
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/v1`,
},
{
source: "/:path*",
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/:path*`,
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/:path*`,
},
]
return {
Expand Down
3 changes: 3 additions & 0 deletions www/apps/api-reference/utils/get-base-path-url.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function getBasePathUrl(path: string): string {
return `${process.env.NEXT_PUBLIC_BASE_PATH}${path}`
}
2 changes: 1 addition & 1 deletion www/apps/api-reference/utils/get-url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from "../config"

export default function getUrl(area: string, tagName?: string): string {
return `${config.baseUrl}/api/${area}#${tagName}`
return `${config.baseUrl}${process.env.NEXT_PUBLIC_BASE_PATH}/${area}#${tagName}`
}
11 changes: 2 additions & 9 deletions www/apps/api-reference/vercel.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
{
"crons": [{
"path": "/api/algolia",
"path": "/v1/api/algolia",
"schedule": "0 0 * * 4"
}],
"framework": "nextjs",
"installCommand": "yarn install",
"buildCommand": "turbo run build",
"outputDirectory": ".next",
"redirects": [
{
"source": "/",
"destination": "/v2",
"permanent": false
}
]
"outputDirectory": ".next"
}
3 changes: 2 additions & 1 deletion www/apps/docs/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ AI_ASSISTANT_URL=
AI_API_ASSISTANT_TOKEN=
AI_WEBSITE_ID=
AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_CLOUD_NAME=
BASE_PATH=
3 changes: 2 additions & 1 deletion www/apps/docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ yarn-error.log*
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions
.vercel
2 changes: 1 addition & 1 deletion www/apps/docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Medusa Documentation

The Medusa documentation website is built with Docusaurus v2. You can learn more about contributing [here](https://docs.medusajs.com/contribution-guidelines).
The Medusa documentation website is built with Docusaurus v2. You can learn more about contributing [here](https://docs.medusajs.com/v1/contribution-guidelines).

## Components and Theme

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,5 @@ export default ProductService

## See Also

- [Store API reference](https://docs.medusajs.com/api/store)
- [Admin API reference](https://docs.medusajs.com/api/admin)
- [Store API reference](https://docs.medusajs.com/v1/api/store)
- [Admin API reference](https://docs.medusajs.com/v1/api/admin)
Original file line number Diff line number Diff line change
Expand Up @@ -219,5 +219,5 @@ export default ProductService

## See Also

- [Store API reference](https://docs.medusajs.com/api/store)
- [Admin API reference](https://docs.medusajs.com/api/admin)
- [Store API reference](https://docs.medusajs.com/v1/api/store)
- [Admin API reference](https://docs.medusajs.com/v1/api/admin)
Original file line number Diff line number Diff line change
Expand Up @@ -946,5 +946,5 @@ You can refer to the [Entities](../entities/create.mdx#adding-relations) and [Se

## See Also

- [Storefront API Reference](https://docs.medusajs.com/api/store)
- [Admin API Reference](https://docs.medusajs.com/api/admin)
- [Storefront API Reference](https://docs.medusajs.com/v1/api/store)
- [Admin API Reference](https://docs.medusajs.com/v1/api/admin)
4 changes: 2 additions & 2 deletions www/apps/docs/content/development/api-routes/create.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -856,5 +856,5 @@ You can refer to the [Entities](../entities/create.mdx#adding-relations) and [Se

## See Also

- [Storefront API Reference](https://docs.medusajs.com/api/store)
- [Admin API Reference](https://docs.medusajs.com/api/admin)
- [Storefront API Reference](https://docs.medusajs.com/v1/api/store)
- [Admin API Reference](https://docs.medusajs.com/v1/api/admin)
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ npm run build
npx medusa develop
```

Then, send a request to the API Route you extended passing it your custom fields. To test out the example in this guide, send an [authenticated request](https://docs.medusajs.com/api/admin#authentication) to the [Create Product API Route](https://docs.medusajs.com/api/admin#products_postproducts) and pass it the `custom_field` body parameter. The request should execute with no errors.
Then, send a request to the API Route you extended passing it your custom fields. To test out the example in this guide, send an [authenticated request](https://docs.medusajs.com/v1/api/admin#authentication) to the [Create Product API Route](https://docs.medusajs.com/v1/api/admin#products_postproducts) and pass it the `custom_field` body parameter. The request should execute with no errors.
4 changes: 2 additions & 2 deletions www/apps/docs/content/development/api-routes/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The Admin APIs are typically accessed from an admin dashboard. For example, you
<DocCardList colSize={6} items={[
{
type: 'link',
href: 'https://docs.medusajs.com/api/store',
href: 'https://docs.medusajs.com/v1/api/store',
label: 'Store APIs',
customProps: {
icon: Icons['server-solid'],
Expand All @@ -25,7 +25,7 @@ The Admin APIs are typically accessed from an admin dashboard. For example, you
},
{
type: 'link',
href: 'https://docs.medusajs.com/api/admin',
href: 'https://docs.medusajs.com/v1/api/admin',
label: 'Admin APIs',
customProps: {
icon: Icons['server-solid'],
Expand Down
Loading

0 comments on commit 9a4e805

Please sign in to comment.