Skip to content

Commit b2a3b9c

Browse files
authored
Merge pull request #2180 from mateuszbartosik/RDoc-3568
RDoc-3568 Fix ID generation for panels
2 parents 4402738 + d631310 commit b2a3b9c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/components/Panel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ export type PanelProps = {
1313
export function Panel(props: PanelProps) {
1414
const { children, className, flush, heading, headingLevel = 2 } = props;
1515
const headingTag = (`h${headingLevel}` as any);
16+
const id = heading.toLowerCase().replace(/[^\w]+/g, '-').replace(/^-|-$/g, '');
1617

1718
return (
1819
<section className={clsx("panel", flush ? "" : "my-4", className)}>
19-
<Heading as={headingTag} className="panel__heading">{heading}</Heading>
20+
<Heading as={headingTag} id={id} className="panel__heading">{heading}</Heading>
2021
<div className="panel__body">
2122
{children}
2223
</div>

0 commit comments

Comments
 (0)