Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/components/ui/common/SiteNoticeBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { basePath } from "../../../metadata";
import { Translation } from "../../../translation/";
import { InfoCircleIcon } from "../../icons";

export const SiteNoticeBanner = () => {
const storageKey = `typst-docs-web${basePath.replace(/\//g, "-")}banner-hidden`;
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The storage key will have consecutive hyphens when basePath is /docs/ (e.g., typst-docs-web-docs--banner-hidden). Consider using .replace(/\//g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '') to normalize the key and avoid leading/trailing/duplicate hyphens.

Suggested change
const storageKey = `typst-docs-web${basePath.replace(/\//g, "-")}banner-hidden`;
const storageKey = `typst-docs-web${basePath.replace(/\//g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "")}-banner-hidden`;

Copilot uses AI. Check for mistakes.
Comment on lines 5 to +6
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The hardcoded prefix typst-docs-web in the storage key should be extracted as a constant at the module level or imported from a configuration file to improve maintainability and consistency across the codebase.

Suggested change
export const SiteNoticeBanner = () => {
const storageKey = `typst-docs-web${basePath.replace(/\//g, "-")}banner-hidden`;
const STORAGE_KEY_PREFIX = "typst-docs-web";
export const SiteNoticeBanner = () => {
const storageKey = `${STORAGE_KEY_PREFIX}${basePath.replace(/\//g, "-")}banner-hidden`;

Copilot uses AI. Check for mistakes.
return (
<div
x-data="{
x-data={`{
bannerVisible: false,
bannerVisibleAfter: 300,
checkBannerStatus() {
const isBannerHidden = localStorage.getItem('typst-jp-banner-hidden') === 'true';
const isBannerHidden = localStorage.getItem('${storageKey}') === 'true';
if (!isBannerHidden) {
setTimeout(() => {
this.bannerVisible = true;
Expand All @@ -18,9 +20,9 @@ export const SiteNoticeBanner = () => {
},
hideBanner() {
this.bannerVisible = false;
localStorage.setItem('typst-jp-banner-hidden', 'true');
localStorage.setItem('${storageKey}', 'true');
}
}"
}`}
x-init="checkBannerStatus()"
x-show="bannerVisible"
x-transition:enter="transition ease-out duration-500"
Expand Down