Merge pull request #32943 from Vivek1819/fix/scaffolder-markdown-links-new-tab

fix(scaffolder): open markdown links in new tab for template outputs
This commit is contained in:
Fredrik Adelöw
2026-04-01 11:49:20 +02:00
committed by GitHub
2 changed files with 20 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/core-components': patch
---
Use Backstage Link component for markdown anchor rendering to ensure consistent internal and external link behavior.
@@ -23,6 +23,7 @@ import { HeadingProps } from 'react-markdown/lib/ast-to-react';
import rehypeRaw from 'rehype-raw';
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
import type { PluggableList } from 'react-markdown/lib/react-markdown';
import { Link } from '../Link';
export type MarkdownContentClassKey = 'markdown';
@@ -109,6 +110,20 @@ const components: Options['components'] = {
h4: headingRenderer,
h5: headingRenderer,
h6: headingRenderer,
a: ({ href, children, title, target, rel }) =>
href ? (
<Link
to={href}
title={title}
{...(target ? { target } : {})}
{...(rel ? { rel } : {})}
>
{children}
</Link>
) : (
<>{children}</>
),
};
const gfmRehypePlugins: PluggableList = [