mirror of
				https://github.com/r-freeman/portfolio.git
				synced 2025-11-04 06:31:11 +00:00 
			
		
		
		
	
		
			All checks were successful
		
		
	
	Build And Publish / BuildAndPublish (push) Successful in 2m35s
				
			
		
			
				
	
	
		
			20 lines
		
	
	
		
			591 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			591 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.5 group-hover:visible invisible'
 | 
						|
                  href={`#${createSlug(headingText)}`}>#</Link>
 | 
						|
        </Component>
 | 
						|
    )
 | 
						|
} |