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:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user