mirror of
https://github.com/r-freeman/portfolio.git
synced 2025-04-18 20:44:46 +00:00
All checks were successful
Build And Publish / BuildAndPublish (push) Successful in 3m15s
19 lines
581 B
TypeScript
19 lines
581 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="flex group">
|
|
{children}
|
|
<Link className="sr-only group-hover:not-sr-only !ml-1.5" href={`#${createSlug(headingText)}`}>#</Link>
|
|
</Component>
|
|
)
|
|
} |