docs: change configurations to make v2 the main docs (#9729)

* docs: change configurations to make v2 the main docs

* move api routes to top level

* remove api prefix

* update opengraph images

* show v1 link

* add redirect to v1
This commit is contained in:
Shahed Nasser
2024-10-24 14:49:58 +03:00
committed by GitHub
parent 471f7e4a10
commit 88f2d17a24
40 changed files with 115 additions and 128 deletions

View File

@@ -4,7 +4,7 @@ NEXT_PUBLIC_DOCS_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_API_ALGOLIA_INDEX_NAME=
NEXT_PUBLIC_ALGOLIA_API_KEY=
NEXT_PUBLIC_ALGOLIA_APP_ID=
NEXT_PUBLIC_ENV=
NEXT_PUBLIC_ENV=development # change to production when running npm start
NEXT_PUBLIC_BASE_URL=
NEXT_PUBLIC_DOCS_URL=
NEXT_PUBLIC_UI_URL=

View File

@@ -838,7 +838,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin
This is useful if you want to extend an API route and pass additional data or perform custom actions.
Refer to [this guide](https://docs.medusajs.com/v2/customization/extend-models/extend-create-product) to find an example of extending an API route.
Refer to [this guide](https://docs.medusajs.com/customization/extend-models/extend-create-product) to find an example of extending an API route.
<Feedback
event="survey_api-ref"

View File

@@ -4,7 +4,7 @@ import DownloadFull from "@/components/DownloadFull"
<H3 className="!mt-0">Just Getting Started?</H3>
Check out the [Medusa v2 Documentation](https://docs.medusajs.com/v2).
Check out the [Medusa v2 Documentation](https://docs.medusajs.com).
<Space bottom={8} />
@@ -16,7 +16,7 @@ To use Medusa's JS SDK library, install the following packages in your project (
npm install @medusajs/js-sdk@latest @medusajs/types@latest
```
Learn more about the JS SDK in [this documentation](https://docs.medusajs.com/v2/resources/js-sdk).
Learn more about the JS SDK in [this documentation](https://docs.medusajs.com/resources/js-sdk).
### Download Full Reference

View File

@@ -270,7 +270,7 @@ and associate placed orders with the specified sales channel.
{/* TODO add v2 links */}
Create a publishable API key either using the [admin REST APIs](https://docs.medusajs.com/v2/api/admin#api-keys_postapikeys), or using the Medusa Admin.
Create a publishable API key either using the [admin REST APIs](https://docs.medusajs.com/api/admin#api-keys_postapikeys), or using the Medusa Admin.
### How to Use a Publishable API Key
@@ -839,7 +839,7 @@ If you click on the workflow, you'll view a reference of that workflow, includin
This is useful if you want to extend an API route and pass additional data or perform custom actions.
Refer to [this guide](https://docs.medusajs.com/v2/customization/extend-models/extend-create-product) to find an example of extending an API route.
Refer to [this guide](https://docs.medusajs.com/customization/extend-models/extend-create-product) to find an example of extending an API route.
<Feedback
event="survey_api-ref"

View File

@@ -1,11 +1,11 @@
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 getSectionId from "../../../utils/get-section-id"
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() {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -1,7 +1,7 @@
import { NextResponse } from "next/server"
import path from "path"
import { existsSync } from "fs"
import getSchemaContent from "../../../utils/get-schema-content"
import getSchemaContent from "../../utils/get-schema-content"
export async function GET(request: Request) {
const { searchParams } = new URL(request.url)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 253 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -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 Specs Collection
</Link>
</Button>

View File

@@ -13,7 +13,7 @@ const TagsOperationDescriptionSectionWorkflowBadge = ({
<p className="my-1">
Workflow{" "}
<Link
href={`${config.baseUrl}/v2/resources/references/medusa-workflows/${workflow}`}
href={`${config.baseUrl}/resources/references/medusa-workflows/${workflow}`}
className="align-middle"
target="_blank"
rel="noreferrer"

View File

@@ -70,7 +70,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
}>(
loadData && tag["x-associatedSchema"]
? basePathUrl(
`/api/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}`
`/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}`
)
: null,
swrFetcher,
@@ -81,9 +81,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
const { data: pathsData } = useSWR<{
paths: PathsObject
}>(
loadData
? basePathUrl(`/api/tag?tagName=${slugTagName}&area=${area}`)
: null,
loadData ? basePathUrl(`/tag?tagName=${slugTagName}&area=${area}`) : null,
swrFetcher,
{
errorRetryInterval: 2000,

View File

@@ -6,7 +6,7 @@ const URL = `${process.env.NEXT_PUBLIC_BASE_URL}${process.env.NEXT_PUBLIC_BASE_P
export async function getBaseSpecs(area: Area) {
try {
const res = await fetch(`${URL}/api/base-specs?area=${area}`, {
const res = await fetch(`${URL}/base-specs?area=${area}`, {
next: {
revalidate: 3000,
tags: [area],

View File

@@ -5,13 +5,22 @@ import rehypeSlug from "rehype-slug"
/** @type {import('next').NextConfig} */
const nextConfig = {
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2/api",
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/api",
webpack: (config) => {
config.ignoreWarnings = [{ module: /node_modules\/keyv\/src\/index\.js/ }]
return config
},
transpilePackages: ["docs-ui"],
async redirects() {
return [
{
source: "/api/download/:path",
destination: "/download/:path",
permanent: true,
},
]
},
}
const withMDX = mdx({

View File

@@ -1,6 +1,6 @@
{
"crons": [{
"path": "/v2/api/api/algolia",
"path": "/api/algolia",
"schedule": "0 0 * * 4"
}],
"framework": "nextjs",

View File

@@ -201,4 +201,4 @@ export default MyCustom
## Properties Reference
Refer to the [Data Model API reference](https://docs.medusajs.com/v2/resources/references/data-model) for a full reference of the properties.
Refer to the [Data Model API reference](!resources!/references/data-model) for a full reference of the properties.

View File

@@ -14,7 +14,7 @@ This chapter covers how to extend the Create Product API route to link a product
## Additional Data in API Routes
Some API routes, including the [Create Product API route](https://docs.medusajs.com/v2/api/admin#products_postproducts), accept an `additional_data` request body parameter.
Some API routes, including the [Create Product API route](!api!/admin#products_postproducts), accept an `additional_data` request body parameter.
It's useful when you want to pass custom data, such as the brand ID, then perform an action based on this data, such as link the brand to the product.

View File

@@ -20,10 +20,10 @@ In this chapter, youll learn how to install and use the Next.js Starter store
},
]} />
1. Clone the `v2` branch of the [Next.js Starter](https://github.com/medusajs/nextjs-starter-medusa/tree/v2):
1. Clone the `v2` branch of the [Next.js Starter](https://github.com/medusajs/nextjs-starter-medusa):
```bash
git clone https://github.com/medusajs/nextjs-starter-medusa -b v2 my-medusa-storefront
git clone https://github.com/medusajs/nextjs-starter-medusa my-medusa-storefront
```
2. Change to the `my-medusa-storefront` directory, install the dependencies, and rename the template environment variable:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -15,7 +15,7 @@ const HomepageLinksSection = () => {
text: "Build a Module",
},
{
href: "https://docs.medusajs.com/v2/resources/integrations",
href: "https://docs.medusajs.com/resources/integrations",
text: "Browse third-party integrations",
},
],
@@ -41,11 +41,11 @@ const HomepageLinksSection = () => {
title: "Storefront Development",
links: [
{
href: "https://docs.medusajs.com/v2/resources/nextjs-starter",
href: "https://docs.medusajs.com/resources/nextjs-starter",
text: "Explore our storefront starter",
},
{
href: "https://docs.medusajs.com/v2/resources/storefront-development",
href: "https://docs.medusajs.com/resources/storefront-development",
text: "Build a custom storefront",
},
{

View File

@@ -17,28 +17,28 @@ const HomepageRecipesSection = () => {
type: "large",
title: "Marketplace",
text: "Build a marketplace with multiple vendors",
href: "https://docs.medusajs.com/v2/resources/recipes/marketplace/examples/vendors",
href: "https://docs.medusajs.com/resources/recipes/marketplace/examples/vendors",
icon: ShopIcon,
},
{
type: "large",
title: "Subscriptions",
text: "Implement a subscription-based commerce store.",
href: "https://docs.medusajs.com/v2/resources/recipes/subscriptions/examples/standard",
href: "https://docs.medusajs.com/resources/recipes/subscriptions/examples/standard",
icon: CalendarRefreshIcon,
},
{
type: "large",
title: "Restaurant-Delivery",
text: "Build a restaurant marketplace inspired by UberEats, with real-time delivery handling",
href: "https://docs.medusajs.com/v2/resources/recipes/marketplace/examples/restaurant-delivery",
href: "https://docs.medusajs.com/resources/recipes/marketplace/examples/restaurant-delivery",
icon: ChefHatIcon,
},
{
type: "large",
title: "Digital Products",
text: "Sell digital products with custom fulfillment.",
href: "https://docs.medusajs.com/v2/resources/recipes/digital-products/examples/standard",
href: "https://docs.medusajs.com/resources/recipes/digital-products/examples/standard",
icon: ImageBinaryIcon,
},
]
@@ -63,7 +63,7 @@ const HomepageRecipesSection = () => {
</span>
</div>
<Link
href={"https://docs.medusajs.com/v2/resources/recipes"}
href={"https://docs.medusajs.com/resources/recipes"}
className="flex gap-0.25 items-center text-compact-small-plus"
withIcon
>

View File

@@ -21,11 +21,11 @@ const withMDX = mdx({
projectUrls: {
resources: {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
path: "v2/resources",
path: "resources",
},
"user-guide": {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
path: "v2/user-guide",
path: "user-guide",
},
ui: {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
@@ -33,7 +33,7 @@ const withMDX = mdx({
},
api: {
url: process.env.NEXT_PUBLIC_RESOURCES_URL,
path: "v2/api",
path: "api",
},
},
useBaseUrl:
@@ -81,29 +81,49 @@ const nextConfig = {
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
transpilePackages: ["docs-ui"],
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2",
async rewrites() {
return {
fallback: [
{
source: "/v2/resources",
source: "/resources",
destination: `${
process.env.NEXT_PUBLIC_RESOURCES_URL || "https://localhost:3001"
}/v2/resources`,
}/resources`,
basePath: false,
},
{
source: "/v2/resources/:path*",
source: "/resources/:path*",
destination: `${
process.env.NEXT_PUBLIC_RESOURCES_URL || "https://localhost:3001"
}/v2/resources/:path*`,
}/resources/:path*`,
basePath: false,
},
{
source: "/v2/api/:path*",
source: "/api",
destination: `${
process.env.NEXT_PUBLIC_API_URL || "https://localhost:3001"
}/v2/api/:path*`,
}/api`,
basePath: false,
},
{
source: "/api/:path*",
destination: `${
process.env.NEXT_PUBLIC_API_URL || "https://localhost:3001"
}/api/:path*`,
basePath: false,
},
{
source: "/v1",
destination: `${
process.env.NEXT_PUBLIC_DOCS_V1_URL || "https://localhost:3001"
}/v1`,
basePath: false,
},
{
source: "/v1/:path*",
destination: `${
process.env.NEXT_PUBLIC_DOCS_V1_URL || "https://localhost:3001"
}/v1/:path*`,
basePath: false,
},
// TODO comment out once we have the user guide published
@@ -123,48 +143,8 @@ const nextConfig = {
async redirects() {
return [
{
source: "/advanced-development/:path*",
destination: "/learn/advanced-development/:path*",
permanent: true,
},
{
source: "/basics/:path*",
destination: "/learn/basics/:path*",
permanent: true,
},
{
source: "/customization/:path*",
destination: "/learn/customization/:path*",
permanent: true,
},
{
source: "/debugging-and-testing/:path*",
destination: "/learn/debugging-and-testing/:path*",
permanent: true,
},
{
source: "/deployment/:path*",
destination: "/learn/deployment/:path*",
permanent: true,
},
{
source: "/first-customizations/:path*",
destination: "/learn/first-customizations/:path*",
permanent: true,
},
{
source: "/more-resources/:path*",
destination: "/learn/more-resources/:path*",
permanent: true,
},
{
source: "/storefront-development/:path*",
destination: "/learn/storefront-development/:path*",
permanent: true,
},
{
source: "/more-resources/examples",
destination: "/resources/examples",
source: "/v2/:path*",
destination: "/:path*",
permanent: true,
},
]

View File

@@ -48,7 +48,7 @@ const SearchProvider = ({ children }: SearchProviderProps) => {
},
],
checkInternalPattern: new RegExp(
`^${config.baseUrl}/v2/([^(resources)])*`
`^${config.baseUrl}/([^(resources)])*`
),
filterOptions: searchFilters,
}}

View File

@@ -32,8 +32,8 @@ module.exports = {
"search-no-result-dark": "url('/images/search-no-result.svg')",
"magnifying-glass": "url('/images/magnifying-glass.svg')",
"magnifying-glass-dark": "url('/images/magnifying-glass-dark.svg')",
"bg-stripes": "url('/v2/images/bg-stripes.png')",
"bg-stripes-dark": "url('/v2/images/bg-stripes-dark.png')",
"bg-stripes": "url('/images/bg-stripes.png')",
"bg-stripes-dark": "url('/images/bg-stripes-dark.png')",
},
},
}

View File

@@ -2388,7 +2388,7 @@ export const myWorkflow = createWorkflow(
)
```
Learn more in [this documentation](https://docs.medusajs.com/v2/advanced-development/workflows/add-workflow-hook).
Learn more in [this documentation](!book!/learn/advanced-development/workflows/add-workflow-hook).
### Retry Steps

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 232 KiB

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -41,7 +41,7 @@ const nextConfig = {
transpilePackages: ["docs-ui"],
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2/resources",
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/resources",
async redirects() {
return [
{

View File

@@ -38,7 +38,7 @@ const SearchProvider = ({ children }: SearchProviderProps) => {
],
},
],
checkInternalPattern: new RegExp(`^${config.baseUrl}/v2/resources/.*`),
checkInternalPattern: new RegExp(`^${config.baseUrl}/resources/.*`),
filterOptions: searchFilters,
}}
commands={[

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

View File

@@ -34,7 +34,7 @@ const withMDX = mdx({
},
api: {
url: process.env.NEXT_PUBLIC_API_URL,
path: "v2/api",
path: "api",
},
},
useBaseUrl:
@@ -82,7 +82,7 @@ const nextConfig = {
transpilePackages: ["docs-ui"],
// TODO uncomment if we decide on baes path
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2/user-guide",
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/user-guide",
}
export default withMDX(nextConfig)

View File

@@ -38,12 +38,12 @@ export const MainNavDesktopMenu = () => {
title: "Homepage",
link: "https://medusajs.com",
},
// {
// type: "link",
// icon: <BookIcon />,
// title: "Medusa v1",
// link: "https://docs.medusajs.com",
// },
{
type: "link",
icon: <BookIcon />,
title: "Medusa v1",
link: "https://docs.medusajs.com/v1",
},
{
type: "link",
icon: <TimelineVertical />,
@@ -54,7 +54,7 @@ export const MainNavDesktopMenu = () => {
type: "link",
icon: <QuestionMarkCircle />,
title: "Troubleshooting",
link: "https://docs.medusajs.com/v2/resources/troubleshooting",
link: "https://docs.medusajs.com/resources/troubleshooting",
},
]

View File

@@ -50,7 +50,7 @@ export const MainNav = ({ className, itemsClassName }: MainNavProps) => {
<SidebarLeftIcon />
</Button>
)}
<Link href={`${config.baseUrl}/v2`}>
<Link href={`${config.baseUrl}`}>
<BorderedIcon
IconComponent={MedusaIcon}
iconWrapperClassName="my-[14px]"

View File

@@ -7,7 +7,7 @@ export const GITHUB_UI_ISSUES_PREFIX = `https://github.com/medusajs/ui/issues/ne
export const navDropdownItems: NavigationItem[] = [
{
type: "link",
path: `/v2/learn`,
path: `/learn`,
title: "Get Started",
project: "book",
},
@@ -18,12 +18,12 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Commerce Modules",
link: "/v2/resources/commerce-modules",
link: "/resources/commerce-modules",
},
{
type: "link",
title: "Architectural Modules",
link: "/v2/resources/architectural-modules",
link: "/resources/architectural-modules",
},
],
},
@@ -34,18 +34,18 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Guides",
link: "/v2/resources",
link: "/resources",
useAsFallback: true,
},
{
type: "link",
title: "Examples",
link: "/v2/resources/examples",
link: "/resources/examples",
},
{
type: "link",
title: "Recipes",
link: "/v2/resources/recipes",
link: "/resources/recipes",
},
{
type: "divider",
@@ -53,12 +53,12 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Admin Components",
link: "/v2/resources/admin-components",
link: "/resources/admin-components",
},
{
type: "link",
title: "Storefront Development",
link: "/v2/resources/storefront-development",
link: "/resources/storefront-development",
},
{
type: "link",
@@ -74,17 +74,17 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Medusa CLI",
link: "/v2/resources/medusa-cli",
link: "/resources/medusa-cli",
},
{
type: "link",
title: "JS SDK",
link: "/v2/resources/js-sdk",
link: "/resources/js-sdk",
},
{
type: "link",
title: "Next.js Starter",
link: "/v2/resources/nextjs-starter",
link: "/resources/nextjs-starter",
},
{
type: "divider",
@@ -92,7 +92,7 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Integrations",
link: "/v2/resources/integrations",
link: "/resources/integrations",
},
],
},
@@ -103,32 +103,32 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "API Routes",
link: "/v2/learn/basics/api-routes",
link: "/learn/basics/api-routes",
},
{
type: "link",
title: "Modules",
link: "/v2/learn/basics/modules",
link: "/learn/basics/modules",
},
{
type: "link",
title: "Subscribers",
link: "/v2/learn/basics/events-and-subscribers",
link: "/learn/basics/events-and-subscribers",
},
{
type: "link",
title: "Scheduled Jobs",
link: "/v2/learn/basics/scheduled-jobs",
link: "/learn/basics/scheduled-jobs",
},
{
type: "link",
title: "Loaders",
link: "/v2/learn/basics/loaders",
link: "/learn/basics/loaders",
},
{
type: "link",
title: "Admin Customizations",
link: "/v2/learn/basics/admin-customizations",
link: "/learn/basics/admin-customizations",
},
{
type: "divider",
@@ -136,22 +136,22 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Links",
link: "/v2/learn/advanced-development/module-links",
link: "/learn/advanced-development/module-links",
},
{
type: "link",
title: "Query",
link: "/v2/learn/advanced-development/module-links/query",
link: "/learn/advanced-development/module-links/query",
},
{
type: "link",
title: "Data Models",
link: "/v2/learn/advanced-development/data-models",
link: "/learn/advanced-development/data-models",
},
{
type: "link",
title: "Workflows",
link: "/v2/learn/basics/workflows",
link: "/learn/basics/workflows",
},
],
},
@@ -162,12 +162,12 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Admin API",
link: "/v2/api/admin",
link: "/api/admin",
},
{
type: "link",
title: "Store API",
link: "/v2/api/store",
link: "/api/store",
},
{
type: "divider",
@@ -175,27 +175,27 @@ export const navDropdownItems: NavigationItem[] = [
{
type: "link",
title: "Workflows",
link: "/v2/resources/medusa-workflows-reference",
link: "/resources/medusa-workflows-reference",
},
{
type: "link",
title: "Data Model API",
link: "/v2/resources/references/data-model",
link: "/resources/references/data-model",
},
{
type: "link",
title: "Service Factory",
link: "/v2/resources/service-factory-reference",
link: "/resources/service-factory-reference",
},
{
type: "link",
title: "Events Reference",
link: "/v2/resources/events-reference",
link: "/resources/events-reference",
},
{
type: "link",
title: "Admin Widget Injection Zones",
link: "/v2/resources/admin-widget-injection-zones",
link: "/resources/admin-widget-injection-zones",
},
],
},