Raw
1 "use client"
2
3 import React from "react"
4 import Link from "next/link"
5 import clsx from "clsx"
6 import { MarkdownSolid } from "@medusajs/icons"
7
8 export type ViewAsMarkdownProps = {
9 /**
10 * The page path (without basePath), e.g. `/store/carts/get-a-cart`.
11 * `next/link` prepends the app's `basePath` (`/api`) automatically.
12 */
13 path: string
14 className?: string
15 }
16
17 /**
18 * A "View as Markdown" link that opens the current section's Markdown (`.md`),
19 * mirroring the other docs apps' `ContentMenuActions`.
20 */
21 const ViewAsMarkdown = ({ path, className }: ViewAsMarkdownProps) => {
22 return (
23 <Link
24 href={`${path}.md`}
25 className={clsx(
26 "flex w-fit items-center gap-docs_0.5 text-medusa-fg-subtle text-x-small-plus hover:text-medusa-fg-base",
27 className
28 )}
29 data-testid="markdown-link"
30 >
31 <MarkdownSolid width={15} height={15} />
32 View as Markdown
33 </Link>
34 )
35 }
36
37 export default ViewAsMarkdown