1 import rehypeMdxCodeProps from "rehype-mdx-code-props"
2 import rehypeSlug from "rehype-slug"
3 import {
4 cloudinaryImgRehypePlugin,
5 resolveAdmonitionsPlugin,
6 crossProjectLinksPlugin,
7 remarkAttachFrontmatterDataPlugin,
8 } from "remark-rehype-plugins"
9 import remarkFrontmatter from "remark-frontmatter"
10 import remarkDirective from "remark-directive"
11 import withExtractedTableOfContents from "@stefanprobst/rehype-extract-toc"
12
13 /** @type {import("@next/mdx").NextMDXOptions} */
14 const mdxPluginOptions = {
15 options: {
16 rehypePlugins: [
17 [
18 crossProjectLinksPlugin,
19 {
20 baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
21 projectUrls: {
22 bloom: {
23 url: process.env.NEXT_PUBLIC_BLOOM_URL,
24 },
25 docs: {
26 url: process.env.NEXT_PUBLIC_DOCS_URL,
27 path: "",
28 },
29 "user-guide": {
30 url: process.env.NEXT_PUBLIC_USER_GUIDE_URL,
31 },
32 ui: {
33 url: process.env.NEXT_PUBLIC_UI_URL,
34 },
35 api: {
36 url: process.env.NEXT_PUBLIC_API_URL,
37 },
38 cloud: {
39 url: process.env.NEXT_PUBLIC_CLOUD_URL,
40 },
41 },
42 useBaseUrl:
43 process.env.NODE_ENV === "production" ||
44 process.env.VERCEL_ENV === "production" ||
45 !!process.env.CLOUDFLARE_ENV,
46 },
47 ],
48 [
49 rehypeMdxCodeProps,
50 {
51 tagName: "code",
52 },
53 ],
54 [rehypeSlug],
55 [
56 cloudinaryImgRehypePlugin,
57 {
58 cloudinaryConfig: {
59 cloudName: process.env.CLOUDINARY_CLOUD_NAME || "",
60 flags: ["fl_lossy", "f_auto"],
61 resize: {
62 action: "pad",
63 aspectRatio: "16:9",
64 },
65 roundCorners: 16,
66 },
67 },
68 ],
69 [withExtractedTableOfContents],
70 ],
71 remarkPlugins: [
72 [remarkFrontmatter],
73 [remarkAttachFrontmatterDataPlugin],
74 [remarkDirective],
75 [resolveAdmonitionsPlugin],
76 ],
77 },
78 }
79
80 export default mdxPluginOptions