docs: update api-reference project for v2 (#7307)

* remove everything v1 and make v2 default

* move main v2 rewrites to book

* move rewrites to book + other fixes
This commit is contained in:
Shahed Nasser
2024-05-16 10:02:35 +03:00
committed by GitHub
parent 9b1998b9b2
commit 22f30f54fd
2148 changed files with 8965 additions and 140283 deletions

View File

@@ -3,41 +3,20 @@
import { Toggle } from "docs-ui"
import clsx from "clsx"
import { usePathname } from "next/navigation"
import { useVersion } from "../../providers/version"
const VersionSwitcher = () => {
const pathname = usePathname()
const { version } = useVersion()
return (
<div className="flex gap-0.5 justify-center items-center">
<span
className={clsx(
version === "1" && "text-medusa-fg-subtle",
version === "2" && "text-medusa-fg-disabled"
)}
>
V1
</span>
<span className={clsx("text-medusa-fg-disabled")}>V1</span>
<Toggle
checked={version === "2"}
onCheckedChange={(checked) => {
let newPath = pathname.replace("/v2", "")
if (checked) {
newPath += `/v2`
}
location.href = location.href.replace(pathname, newPath)
checked={true}
onCheckedChange={() => {
location.href = process.env.NEXT_PUBLIC_API_V1_URL + pathname
}}
/>
<span
className={clsx(
version === "1" && "text-medusa-fg-disabled",
version === "2" && "text-medusa-fg-subtle"
)}
>
V2
</span>
<span className={clsx("text-medusa-fg-subtle")}>V2</span>
</div>
)
}