feat(components): implement Head for each page with reusability
This commit is contained in:
parent
64190593dd
commit
2e0aecd153
32
components/Head/NextHead.tsx
Normal file
32
components/Head/NextHead.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import Head from 'next/head'
|
||||
|
||||
import { projectConfig } from '@/utils/config'
|
||||
|
||||
interface HeadProps {
|
||||
longName?: string
|
||||
shortName?: string
|
||||
}
|
||||
|
||||
const NextHead: React.FC<HeadProps> = (props) => {
|
||||
const {
|
||||
longName = projectConfig.longName,
|
||||
shortName = projectConfig.shortName,
|
||||
children
|
||||
} = props
|
||||
|
||||
return (
|
||||
<Head>
|
||||
<title>
|
||||
{props.longName == null
|
||||
? longName
|
||||
: props.shortName == null && shortName}
|
||||
</title>
|
||||
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
|
||||
|
||||
{children}
|
||||
</Head>
|
||||
)
|
||||
}
|
||||
|
||||
export default NextHead
|
@ -1,6 +1,6 @@
|
||||
import type { NextPage } from 'next'
|
||||
|
||||
import Head from '../components/Head'
|
||||
import Head from '../components/Head/NextHead'
|
||||
|
||||
const Home: NextPage = () => {
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user