docs: prepare projects configurations for user guide (#11610)

* docs: prepare projects configurations for user guide

* fix build error
This commit is contained in:
Shahed Nasser
2025-02-26 10:01:30 +02:00
committed by GitHub
parent 9e2af4801d
commit b45c1e1580
5 changed files with 59 additions and 17 deletions
+4 -1
View File
@@ -48,6 +48,9 @@ const withMDX = createMDX({
projectPath: path.resolve("..", "ui"), projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs", contentPath: "src/content/docs",
}, },
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
},
}, },
}, },
], ],
@@ -91,4 +94,4 @@ const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE_BUNDLE === "true", enabled: process.env.ANALYZE_BUNDLE === "true",
}) })
export default withMDX(nextConfig) export default withMDX(withBundleAnalyzer(nextConfig))
+13 -11
View File
@@ -28,6 +28,9 @@ const withMDX = mdx({
projectPath: path.resolve("..", "ui"), projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs", contentPath: "src/content/docs",
}, },
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
},
}, },
}, },
], ],
@@ -152,17 +155,16 @@ const nextConfig = {
}/v1/:path*`, }/v1/:path*`,
basePath: false, basePath: false,
}, },
// TODO comment out once we have the user guide published {
// { source: "/user-guide",
// source: "/user-guide", destination: `${process.env.NEXT_PUBLIC_USER_GUIDE_URL || "https://localhost:3001"}/user-guide`,
// destination: `${process.env.NEXT_PUBLIC_USER_GUIDE_URL}/user-guide`, basePath: false,
// basePath: false, },
// }, {
// { source: "/user-guide/:path*",
// source: "/user-guide/:path*", destination: `${process.env.NEXT_PUBLIC_USER_GUIDE_URL || "https://localhost:3001"}/user-guide/:path*`,
// destination: `${process.env.NEXT_PUBLIC_USER_GUIDE_URL}/user-guide/:path*`, basePath: false,
// basePath: false, },
// },
], ],
} }
}, },
+3
View File
@@ -26,6 +26,9 @@ const withMDX = mdx({
projectPath: path.resolve("..", "ui"), projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs", contentPath: "src/content/docs",
}, },
"user-guide": {
projectPath: path.resolve("..", "user-guide"),
},
}, },
}, },
], ],
@@ -16,7 +16,7 @@ type Params = {
} }
export async function GET(req: NextRequest, { params }: Params) { export async function GET(req: NextRequest, { params }: Params) {
const { slug } = await params const { slug = ["/"] } = await params
// keep this so that Vercel keeps the files in deployment // keep this so that Vercel keeps the files in deployment
const basePath = path.join(process.cwd(), "app") const basePath = path.join(process.cwd(), "app")
+38 -4
View File
@@ -1,4 +1,5 @@
import mdx from "@next/mdx" import mdx from "@next/mdx"
import path from "path"
import rehypeMdxCodeProps from "rehype-mdx-code-props" import rehypeMdxCodeProps from "rehype-mdx-code-props"
import rehypeSlug from "rehype-slug" import rehypeSlug from "rehype-slug"
import remarkDirective from "remark-directive" import remarkDirective from "remark-directive"
@@ -9,13 +10,32 @@ import {
cloudinaryImgRehypePlugin, cloudinaryImgRehypePlugin,
resolveAdmonitionsPlugin, resolveAdmonitionsPlugin,
crossProjectLinksPlugin, crossProjectLinksPlugin,
prerequisitesLinkFixerPlugin,
} from "remark-rehype-plugins" } from "remark-rehype-plugins"
import bundleAnalyzer from "@next/bundle-analyzer"
const withMDX = mdx({ const withMDX = mdx({
extension: /\.mdx?$/, extension: /\.mdx?$/,
options: { options: {
rehypePlugins: [ rehypePlugins: [
// TODO add V2 to path if necessary [
brokenLinkCheckerPlugin,
{
crossProjects: {
docs: {
projectPath: path.resolve("..", "book"),
},
ui: {
projectPath: path.resolve("..", "ui"),
contentPath: "src/content/docs",
},
resources: {
projectPath: path.resolve("..", "resources"),
hasGeneratedSlugs: true,
},
},
},
],
[ [
crossProjectLinksPlugin, crossProjectLinksPlugin,
{ {
@@ -40,7 +60,6 @@ const withMDX = mdx({
process.env.VERCEL_ENV === "production", process.env.VERCEL_ENV === "production",
}, },
], ],
[brokenLinkCheckerPlugin],
[localLinksRehypePlugin], [localLinksRehypePlugin],
[ [
rehypeMdxCodeProps, rehypeMdxCodeProps,
@@ -63,6 +82,12 @@ const withMDX = mdx({
}, },
}, },
], ],
[
prerequisitesLinkFixerPlugin,
{
checkLinksType: "value",
},
],
], ],
remarkPlugins: [ remarkPlugins: [
[remarkFrontmatter], [remarkFrontmatter],
@@ -79,8 +104,17 @@ const nextConfig = {
pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"], pageExtensions: ["js", "jsx", "mdx", "ts", "tsx"],
transpilePackages: ["docs-ui"], transpilePackages: ["docs-ui"],
// TODO uncomment if we decide on baes path
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/user-guide", basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/user-guide",
outputFileTracingExcludes: {
"*": ["node_modules/@medusajs/icons"],
},
experimental: {
optimizePackageImports: ["@medusajs/icons", "@medusajs/ui"],
},
} }
export default withMDX(nextConfig) const withBundleAnalyzer = bundleAnalyzer({
enabled: process.env.ANALYZE === "true",
})
export default withMDX(withBundleAnalyzer(nextConfig))