Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ export const rewriteInternalLinksPlugin = ({ entry, versionMetadata }) => {
// Transforms the syntax tree by rewriting internal links to include the version.
return flatMap(tree, (node) => {
// Check if the node is a link and matches the pattern for links to rewrite
if (node.type === 'link' && isLinkToRewritePattern.test(node.url)) {
if (
(node.type === 'link' || node.type === 'definition') &&
isLinkToRewritePattern.test(node.url)
) {
const splitUrl = node.url.split('/')
const hasVersionInPath = splitUrl.find((el) => {
return (
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for adding the test case!

Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,19 @@ describe('transformRewriteInternalLinks', () => {
)
expect(result).toBe(expectedOutput)
})

it('should rewrite definitions that include links', async () => {
const content = `[definition]: /terraform/language/some-page`
const entry = {
filePath: 'content/terraform/v1.5.x/docs/language/some-file.mdx',
}
const expectedOutput =
'[definition]: /terraform/language/v1.5.x/some-page\n'
const result = await transformRewriteInternalLinks(
content,
entry,
versionMetadata,
)
expect(result).toBe(expectedOutput)
})
})
Binary file modified scripts/prebuild/prebuild-arm-linux-binary.gz
Binary file not shown.
Binary file modified scripts/prebuild/prebuild-arm-mac-binary.gz
Binary file not shown.
Binary file modified scripts/prebuild/prebuild-x64-linux-binary.gz
Binary file not shown.
Loading