Fix ts issue
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m36s

This commit is contained in:
r-freeman 2024-09-19 16:00:03 +01:00
parent efbac85b5a
commit 3a5de79115

View File

@ -1,4 +1,3 @@
// @ts-nocheck
import {ElementType, ReactNode} from 'react' import {ElementType, ReactNode} from 'react'
import {createSlug} from '@/lib/createSlug' import {createSlug} from '@/lib/createSlug'
import Link from 'next/link' import Link from 'next/link'
@ -8,12 +7,14 @@ type HeadingProps = {
children: ReactNode children: ReactNode
} }
export function Heading({as: Component = 'h1', children}: HeadingProps) { export function Heading({as: Component = 'h1', children = null}: HeadingProps) {
let headingText = children ? children.toString() : ''
return ( return (
<Component id={createSlug(children.toString())} className='group'> <Component id={createSlug(headingText)} className='group'>
{children} {children}
<Link className='ml-1 group-hover:opacity-100 opacity-0 transition-opacity ease-in' <Link className='ml-1 group-hover:opacity-100 opacity-0 transition-opacity ease-in'
href={`#${createSlug(children.toString())}`}>#</Link> href={`#${createSlug(headingText)}`}>#</Link>
</Component> </Component>
) )
} }