Changed types to be more specific
Signed-off-by: John Philip <johnphilip283@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ import gfm from 'remark-gfm';
|
||||
import React from 'react';
|
||||
import { BackstageTheme } from '@backstage/theme';
|
||||
import { CodeSnippet } from '../CodeSnippet';
|
||||
import { HeadingProps } from 'react-markdown/lib/ast-to-react';
|
||||
|
||||
export type MarkdownContentClassKey = 'markdown';
|
||||
|
||||
@@ -73,13 +74,15 @@ type Props = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const flatten = (text, child) => {
|
||||
const flatten = (text: string, child: any): string => {
|
||||
if (!child) return text;
|
||||
|
||||
return typeof child === 'string'
|
||||
? text + child
|
||||
: React.Children.toArray(child.props.children).reduce(flatten, text);
|
||||
};
|
||||
|
||||
const headingRenderer = ({ level, children }) => {
|
||||
const headingRenderer = ({ level, children }: HeadingProps) => {
|
||||
const childrenArray = React.Children.toArray(children);
|
||||
const text = childrenArray.reduce(flatten, '');
|
||||
const slug = text.toLocaleLowerCase('en-US').replace(/\W/g, '-');
|
||||
|
||||
Reference in New Issue
Block a user