Skip to content

Conversation

@mportiz08
Copy link
Contributor

Bug/issue #, if applicable: 142337934

Summary

This updates the logic used to choose between multiple top-level trees of data for the sidebar navigator:

Before, it would pick the first module in the list. (see #916)

Now, it will pick the first node with a path prefix matches the path prefix of the current URL.

This logic should only apply to rare scenarios where multiple trees of index data are included in a single Index JSON file.

Testing

Steps:

  1. Verify that there are no regressions with loading sidebar data in common, single-root scenarios.
  2. Verify that the data loaded for the index generally matches what would be expected given the current URL in scenarios where there are multiple roots of index data.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

@mportiz08
Copy link
Contributor Author

@swift-ci test

@mportiz08
Copy link
Contributor Author

@swift-ci test

Copy link
Member

@marinaaisa marinaaisa left a comment

Choose a reason for hiding this comment

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

I'm not very happy about relying on window.location but I haven't found a better alternative.

I tried a different approach where I imported the Vue's router into the navigatorData.js file and used currentRoute.fullPath to retrieve the path without the baseUrl prefix.

It wasn't cleaner than using window.location and it had some potentially risky changes in the main.js file so I don't think it's a good alternative.

Let's go with this approach then! Thank you @mportiz08

@mportiz08 mportiz08 merged commit 1fe0a7a into swiftlang:main Mar 4, 2025
1 check passed
@mportiz08 mportiz08 deleted the rely-on-url-for-index-fallback branch March 4, 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.

3 participants