diff --git a/docs/.vitepress/theme/banner.ts b/docs/.vitepress/theme/banner.ts index b4b866628..6aa022cc3 100644 --- a/docs/.vitepress/theme/banner.ts +++ b/docs/.vitepress/theme/banner.ts @@ -6,6 +6,7 @@ interface BannerData { message: string; link?: string; linkText?: string; + expires?: string; } const ENDPOINT = "https://jdx.dev/banner.json"; @@ -17,12 +18,20 @@ export function initBanner(): void { .then((r) => (r.ok ? (r.json() as Promise) : null)) .then((b) => { if (!b || !b.enabled) return; + if (isExpired(b.expires)) return; if (localStorage.getItem(STORAGE_KEY) === b.id) return; render(b); }) .catch(() => {}); } +function isExpired(expires: string | undefined): boolean { + if (!expires) return false; + const t = Date.parse(expires); + if (Number.isNaN(t)) return false; + return Date.now() >= t; +} + function isHttpUrl(value: string): boolean { try { const u = new URL(value, window.location.href);