mirror of
https://github.com/r-freeman/portfolio.git
synced 2024-11-15 02:55:42 +00:00
r-freeman
3a5de79115
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 2m36s
20 lines
620 B
TypeScript
20 lines
620 B
TypeScript
import {ElementType, ReactNode} from 'react'
|
|
import {createSlug} from '@/lib/createSlug'
|
|
import Link from 'next/link'
|
|
|
|
type HeadingProps = {
|
|
as?: ElementType
|
|
children: ReactNode
|
|
}
|
|
|
|
export function Heading({as: Component = 'h1', children = null}: HeadingProps) {
|
|
let headingText = children ? children.toString() : ''
|
|
|
|
return (
|
|
<Component id={createSlug(headingText)} className='group'>
|
|
{children}
|
|
<Link className='ml-1 group-hover:opacity-100 opacity-0 transition-opacity ease-in'
|
|
href={`#${createSlug(headingText)}`}>#</Link>
|
|
</Component>
|
|
)
|
|
} |