Skip to content

Conversation

@josh-wong
Copy link
Member

Description

This pull request introduces a new in-site notification feature to enhance visitor engagement by displaying notifications in the navigation bar at the top of the page in both English and Japanese. The changes include adding a custom notification bell component, integrating it into the navbar, and styling it for both desktop and mobile views. Additionally, a data structure and utility functions were implemented to manage notifications dynamically based on user language and read status.

Related issues and/or PRs

N/A

Changes made

Notification feature implementation:

  • src/components/NotificationBell.tsx: Added the NotificationBell component to display notifications, track read/unread status, and handle user interactions. Notifications are fetched dynamically and support language-specific (English or Japanese) messages.
  • src/data/notifications.js: Created this file to define notification data and utility functions, including getNotifications for fetching notifications based on language and detectLanguage for determining the user's language from the URL.
  • src/theme/NavbarItem/index.tsx: Modified to include the custom notification bell in the navbar when the item type is custom-NotificationBell. Notifications are passed dynamically to the component.

Configuration and styling

  • docusaurus.config.js: Updated to include the custom notification bell in the navbar and import the notification data. [1] [2]
  • src/css/custom.css: Added styles for the notification bell, dropdown, and responsive behavior. Includes support for dark mode and mobile-specific adjustments.

Dependency updates

  • package.json: Added @fortawesome/fontawesome-free for consistent icon usage across the notification bell component.

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have updated the side navigation as necessary.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

@josh-wong josh-wong requested a review from Copilot May 7, 2025 06:15
@josh-wong josh-wong self-assigned this May 7, 2025
@josh-wong josh-wong added the enhancement New feature or request label May 7, 2025
Copy link

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 introduces an in-site notification feature for Docusaurus to enhance visitor engagement by displaying localized notifications in the navigation bar. Key changes include:

  • Implementation of a custom NotificationBell React component to handle notification display and interaction.
  • Creation of a notifications data structure and utility functions to support language-specific notifications.
  • Modifications in the navbar and configuration to integrate the notification feature.

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

File Description
src/theme/NavbarItem/index.tsx Wraps the custom NotificationBell component and fetches language‐specific notifications.
src/data/notifications.js Defines notifications, utility functions to fetch/update notifications and detect language.
src/components/NotificationBell.tsx Implements the NotificationBell component to display notifications and manage read status.
docusaurus.config.js Updates configuration to include the custom notification bell in the navbar.
Files not reviewed (2)
  • package.json: Language not supported
  • src/css/custom.css: Language not supported

@scalar-labs scalar-labs deleted a comment from Copilot AI May 7, 2025
@josh-wong josh-wong marked this pull request as draft May 8, 2025 10:14
@josh-wong josh-wong marked this pull request as ready for review May 8, 2025 11:19
@josh-wong josh-wong merged this pull request into main May 9, 2025
1 check passed
@josh-wong josh-wong deleted the docusaurus/add-in-site-notification-feature branch May 9, 2025 03:08
josh-wong added a commit that referenced this pull request May 14, 2025
* Create NotificationBell.tsx

* Create index.tsx

* Create notifications.js

* Add custom notification function

* Add styles for notification icon and dropdown

* Fix question mark tooltip overlap issue

* Add `@fortawesome/fontawesome-free`

* Fix image background color on zoom

* Allow each language to have its own URL

* Add notification messages

* Make notification message font larger

* Fix broken relative links

Clicking a link in the notification dropdown and then clicking another link resulted in a broken link because the relative path was taken into account when then next link was clicked. For example, if the relative link was `AAA/BBB`, then when the link `CCC/DDD` was selected, the URL would be `AAA/CCC/DDD`. This commit ensures that the base URL is called first and then the relative link in the notification message is applied to that base link.

* Add `Blog post` to notification message

* Add missing ending curly bracket

* Remove duplicate bell icon

* Fix grammar

* Change object name from `languages` to `message`

* Add automatic version tracking for content changes

Implemented content fingerprinting to detect changes in notification messages and URLs. When content changes, the system automatically increments the version number, marking the notification as unread.
@josh-wong josh-wong restored the docusaurus/add-in-site-notification-feature branch May 27, 2025 05:13
@josh-wong josh-wong deleted the docusaurus/add-in-site-notification-feature branch May 27, 2025 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant