Skip to content

Commit 2b9714f

Browse files
authored
fix: use base-dependent local storage key for banner state (#32)
1 parent 544f74c commit 2b9714f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/ui/common/SiteNoticeBanner.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
import { basePath } from "../../../metadata";
12
import { Translation } from "../../../translation/";
23
import { InfoCircleIcon } from "../../icons";
34

45
export const SiteNoticeBanner = () => {
6+
const storageKey = `typst-docs-web${basePath.replace(/\//g, "-")}banner-hidden`;
57
return (
68
<div
7-
x-data="{
9+
x-data={`{
810
bannerVisible: false,
911
bannerVisibleAfter: 300,
1012
checkBannerStatus() {
11-
const isBannerHidden = localStorage.getItem('typst-jp-banner-hidden') === 'true';
13+
const isBannerHidden = localStorage.getItem('${storageKey}') === 'true';
1214
if (!isBannerHidden) {
1315
setTimeout(() => {
1416
this.bannerVisible = true;
@@ -18,9 +20,9 @@ export const SiteNoticeBanner = () => {
1820
},
1921
hideBanner() {
2022
this.bannerVisible = false;
21-
localStorage.setItem('typst-jp-banner-hidden', 'true');
23+
localStorage.setItem('${storageKey}', 'true');
2224
}
23-
}"
25+
}`}
2426
x-init="checkBannerStatus()"
2527
x-show="bannerVisible"
2628
x-transition:enter="transition ease-out duration-500"

0 commit comments

Comments
 (0)