Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: redirect for patch routes #247

Merged
merged 1 commit into from
Mar 20, 2025
Merged

feat: redirect for patch routes #247

merged 1 commit into from
Mar 20, 2025

Conversation

elibosley
Copy link
Member

@elibosley elibosley commented Mar 20, 2025

Before Submitting This PR, Please Ensure You Have Completed The Following:

  1. Are internal links to wiki documents using relative file links?
  2. Are all new documentation files lowercase, with dash separated names (ex. unraid-os.mdx)?
  3. Are all assets (images, etc), located in an assets/ subfolder next to the .md/mdx files?
  4. Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  5. Is the build succeeding?

Summary by CodeRabbit

  • New Features

    • Introduced enhanced URL redirection that automatically guides users from version-specific release notes to the correct patch section for smoother navigation.
  • Chores

    • Improved configuration consistency and updated dependency versions to ensure maintainability without affecting the overall functionality.

@elibosley elibosley requested a review from ljm42 March 20, 2025 02:01
Copy link
Contributor

coderabbitai bot commented Mar 20, 2025

Walkthrough

This update refines the Docusaurus configuration and introduces a new redirection feature. The docusaurus.config.js file has been reformatted for consistency, with a new scripts array added to load a client-side redirection script. The package.json file now specifies an updated version for the @docusaurus/plugin-client-redirects dependency. A new file, static/js/redirects.js, implements URL pattern matching and manages redirection based on Unraid release notes versioning.

Changes

File(s) Summary
docusaurus.config.js Added scripts: [{ src: "/js/redirects.js", async: false }]; updated string quotes for searchPagePath and additionalLanguages; reformatted keywords metadata entry for improved readability.
package.json Updated the dependency version of @docusaurus/plugin-client-redirects from "^3.3.2" to "^3.7.0".
static/js/redirects.js New file added that implements client-side redirection by matching URLs against a pattern and redirecting to a patched version section based on the extracted version number.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant B as Browser
    participant R as RedirectScript
    U->>B: Request "/unraid-os/release-notes/X.Y.Z+patch.N"
    B->>B: Load page (includes docusaurus.config.js)
    B->>R: Execute redirects.js
    R->>R: Match URL against regex pattern
    alt Pattern matches
        R->>B: Set window.location.href to "/unraid-os/release-notes/{baseVersion}#patches"
    else No match
        R->>B: No redirection, normal flow continues
    end
Loading

Possibly related PRs

Suggested reviewers

  • ljm42
  • spencerjunraid

Poem

Oh, I'm a rabbit with ears so keen,
Hopping through code in files unseen.
Adding a script to lead the way,
For URLs to find their perfect display.
With a twitch of my nose, watch changes unfurl,
Leaping through updates in our digital world!
🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 9472f5b and f3a37ff.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • docusaurus.config.js (5 hunks)
  • package.json (1 hunks)
  • static/js/redirects.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • static/js/redirects.js
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (4)
docusaurus.config.js (4)

37-42: Addition of client-side redirect script looks good.

The implementation of a new client-side redirection script is aligned with the PR's objective of adding redirects for patch routes. Setting async: false ensures the script executes before page content loads, which is appropriate for a redirection script.


4-5: Consistent quote formatting improves code style.

The formatting changes from single quotes to double quotes throughout the file improve code style consistency. This is a good practice and makes the codebase more maintainable.

Also applies to: 89-89, 213-220


111-115: Improved readability for metadata keywords.

The reformatting of the keywords metadata entry improves readability while maintaining the same content. This multi-line approach is easier to read and maintain than a single long line.


37-41: Consider performance impact of synchronous script loading.

The redirection script is loaded with async: false, which blocks rendering until the script completes execution. While this ensures redirects happen before page content loads, it could affect page load performance, especially if the script is large or if there are network delays.

Consider measuring the performance impact and potentially adding a comment explaining why synchronous loading is necessary for this specific script.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
static/js/redirects.js (1)

1-18: Clean implementation of the redirect mechanism.

The script effectively handles redirections for patch releases by capturing the base version from URLs matching the pattern /unraid-os/release-notes/X.Y.Z+patch.N and redirecting to the patches section of the corresponding main version page.

However, consider adding some basic error handling in case anything unexpected happens during redirection:

 if (match) {
   // Get the base version (X.Y.Z)
   const baseVersion = match[1];
   
   // Redirect to the patches section of that version
+  try {
     window.location.href = `/unraid-os/release-notes/${baseVersion}#patches`;
+  } catch (e) {
+    console.error('Failed to redirect:', e);
+  }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5d2a0 and 9472f5b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • docusaurus.config.js (5 hunks)
  • package.json (1 hunks)
  • static/js/redirects.js (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: AWS Amplify Console Web Preview
🔇 Additional comments (3)
package.json (1)

21-21: Good alignment of dependency versions.

Updating the @docusaurus/plugin-client-redirects to version ^3.7.0 brings it in line with other Docusaurus dependencies like @docusaurus/core and @docusaurus/preset-classic, ensuring better consistency and compatibility.

docusaurus.config.js (2)

37-42: Well-organized integration of client-side redirect script.

The configuration properly includes the new redirects.js script with async: false to ensure it loads and executes before page rendering, which is appropriate for redirection logic that needs to run immediately.


89-89: Good consistency improvements in formatting.

The switch to double quotes for string literals and the reformatting of the keywords metadata improves code consistency and readability without changing functionality.

Also applies to: 111-115, 213-213, 216-220

@elibosley elibosley force-pushed the feat/patch-redirection branch from 9472f5b to f3a37ff Compare March 20, 2025 02:04
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-247.d1o5s833kbd339.amplifyapp.com

@elibosley elibosley merged commit f05d1ad into main Mar 20, 2025
3 checks passed
@elibosley elibosley deleted the feat/patch-redirection branch March 20, 2025 21:12
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.

2 participants