Skip to content

Conversation

@3w36zj6
Copy link
Member

@3w36zj6 3w36zj6 commented Nov 1, 2025

close #19

@3w36zj6 3w36zj6 requested a review from Copilot November 1, 2025 00:49
@netlify
Copy link

netlify bot commented Nov 1, 2025

Deploy Preview for typst-docs-web ready!

Name Link
🔨 Latest commit cf7d05f
🔍 Latest deploy log https://app.netlify.com/projects/typst-docs-web/deploys/690559023561410008e4b380
😎 Deploy Preview https://deploy-preview-32--typst-docs-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the SiteNoticeBanner component to make the localStorage key dynamic based on the basePath configuration, replacing the hardcoded 'typst-jp-banner-hidden' key. This ensures that different deployments with different base paths maintain separate banner visibility states.

Key Changes

  • Import basePath from metadata to make the storage key configurable
  • Generate a dynamic storage key by replacing forward slashes in basePath with hyphens
  • Update the Alpine.js x-data attribute from a static string to a template literal to interpolate the storage key

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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
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.

[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.
Copy link
Member

@YDX-2147483647 YDX-2147483647 left a comment

Choose a reason for hiding this comment

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

Good. I confirmed that the banner on each sub-website in the deploy preview is controlled independently.

@3w36zj6 3w36zj6 merged commit 2b9714f into main Nov 1, 2025
20 checks passed
@3w36zj6 3w36zj6 deleted the feature/use-base-dependent-local-storage-key-for-banner branch November 1, 2025 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the local storage key

3 participants