Repository navigation
Re-show dismissed announcement bar after 10 days - #1778
derek-netwrix wants to merge 1 commit into
Conversation
Docusaurus remembers a dismissal forever. Add a client module that stamps the first time it sees the bar dismissed and clears the dismissal once the stamp is older than 10 days. Generated with AI Co-Authored-By: Claude Code <ai@netwrix.com>
Code ReviewThe config change and the new client module are fine. The SSR guard is correct, storage errors are caught, the storage key matches Docusaurus's unnamespaced default (no The bar can stay hidden on the page load where the dismissal expires ( Docusaurus injects an inline On the load where the 10 days run out, the attribute is already A small fix is to reset the attribute when the dismissal is cleared: } else if (Date.now() - stamp > SHOW_AGAIN_AFTER_DAYS * 24 * 60 * 60 * 1000) {
localStorage.removeItem(DISMISS_KEY);
localStorage.removeItem(STAMP_KEY);
document.documentElement.setAttribute('data-announcement-bar-initially-dismissed', 'false');
}This is worth checking in a browser: set Two smaller notes, no change needed:
|
Summary
idchanges). This addssrc/clientModules/announcementBarExpiry.js, which stamps the first time it sees the bar dismissed and clears the dismissal once the stamp is older than 10 days.clientModulesindocusaurus.config.js.Notes
announcementBar.idstill re-shows it to everyone immediately.localStorage: first sighting stamps, 9 days stays dismissed, 11 days clears.Generated with AI
Co-Authored-By: Claude Code ai@netwrix.com