-
Notifications
You must be signed in to change notification settings - Fork 79
fix: update internal links transform to run for all products #994
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
Conversation
Vercel Previews Deployed
|
scripts/prebuild/mdx-transforms/add-version-to-internal-links/add-version-to-internal-links.mjs
Show resolved
Hide resolved
}) | ||
// Replace the matched part of the URL with the versioned path if no version is present | ||
if (!hasVersionInPath) { | ||
node.url = node.url.replace(replacePattern, `/$1/${cleanVersion}$2`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here be dragons....
We might want to be careful here with this logic as this has caused issues on dev portal URL slugs that contain versions. You can see an example of this here where the links in the dropdown get truncated to https://developer.hashicorp.com/vault/docs/v1.19.x/upgrading/upgrade-to-
.
I have a dev portal PR open here. I don't know how likely we are to run into that here, but it just seemed worth mentioning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is something I made sure to double check with the regexes I've used here. These regexes include ^
at the beginning which means that the string must start with the version. This means strings like upgrade-to-0.9.2
do not pass the regex. Here are a few example of this:
https://unified-docs-frontend-preview-i54wv6l6r-hashicorp.vercel.app/vault/docs/v1.10.x/commands - upgrade guide link at top of page
https://unified-docs-frontend-preview-i54wv6l6r-hashicorp.vercel.app/vault/docs/v1.10.x/deprecation - Filter Mount Replication Deprecation Notice link in the table
https://unified-docs-frontend-preview-i54wv6l6r-hashicorp.vercel.app/vault/docs/v1.10.x/faq/ssct - Upgrade to 1.10 link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah gotcha. Somehow I didn't notice the caret at first!
…orp/web-unified-docs into leah/fix/internal-links-transform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. 👍🏻
Description
This PR updates the internal links transform so it runs for all products. This is done by setting up basePaths for each product that doesn't have them in the product config. The old mktg-content-workflow would parse the code and dynamically update these basePaths for each product but since we've changed things for UDR, it is best to manually add the basePaths here for more clarity.
This PR also includes adding a check to determine if the link being changed already has a version in it. If it does, it won't rewrite it to add the current version. This is necessary since some pages include links that authors have manually added a version to.
Testing