Skip to content

Commit 7bf2dec

Browse files
committed
refactor(docs): simplify VersionSwitcher with hardcoded current version
1 parent bb6fd06 commit 7bf2dec

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

docs/components/latest-version-banner.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useEffect, useState } from "react";
44
import { Banner } from "fumadocs-ui/components/banner";
5+
import { IconArrowRightLine } from "@karrotmarket/react-monochrome-icon";
56

67
export function LatestVersionBanner() {
78
const [show, setShow] = useState(false);
@@ -17,9 +18,9 @@ export function LatestVersionBanner() {
1718

1819
return (
1920
<Banner id="latest-version">
20-
프리뷰 또는 이전 버전의 문서를 보고 있습니다.{" "}
21-
<a href="https://seed-design.io" className="font-medium underline">
22-
seed-design.io 방문
21+
프리뷰 또는 이전 버전의 문서를 보고 있습니다.
22+
<a href="https://seed-design.io" className="ml-1 font-medium underline">
23+
seed-design.io 방문 <IconArrowRightLine className="ml-0.5 size-3.5" />
2324
</a>
2425
</Banner>
2526
);

docs/components/react-version-switcher.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client";
22

33
import { IconCheckmarkLine, IconChevronDownLine } from "@karrotmarket/react-monochrome-icon";
4-
import { useEffect, useState } from "react";
4+
import { useState } from "react";
55
import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
66
import { buttonVariants } from "fumadocs-ui/components/ui/button";
77
import { cva } from "class-variance-authority";
@@ -12,19 +12,17 @@ const VERSIONS = [
1212
{ label: "v1.0", url: "https://1-0.seed-design.pages.dev/react" },
1313
] as const satisfies ReadonlyArray<{ label: string; url: string }>;
1414

15+
// NOTE: update CURRENT_VERSION when releasing a new version & keep in release branch
16+
const CURRENT_VERSION: (typeof VERSIONS)[number]["label"] = "v1.2 (latest)";
17+
1518
const itemVariants = cva(
1619
"text-sm p-2 rounded-lg inline-flex items-center gap-2 hover:text-fd-accent-foreground hover:bg-fd-accent [&_svg]:size-4",
1720
);
1821

1922
export function ReactVersionSwitcher() {
2023
const [open, setOpen] = useState(false);
21-
const [hostname, setHostname] = useState("");
22-
23-
useEffect(() => {
24-
setHostname(window.location.hostname);
25-
}, []);
2624

27-
const current = VERSIONS.find((v) => new URL(v.url).hostname === hostname) ?? VERSIONS[0];
25+
const current = VERSIONS.find((v) => v.label === CURRENT_VERSION) ?? VERSIONS[0];
2826

2927
return (
3028
<Popover open={open} onOpenChange={setOpen}>

0 commit comments

Comments
 (0)