-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ implement custom Head component with defaults and OG/Twitter …
…support
- Loading branch information
1 parent
c5e8682
commit a073a26
Showing
5 changed files
with
223 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import NextHead from "next/head"; | ||
|
||
interface HeadProps { | ||
children?: React.ReactNode; | ||
pageTitle: string; | ||
description?: string; | ||
url?: string; | ||
image?: string | null; | ||
video?: string | null; | ||
ogType?: "article" | "website" | "post"; | ||
twitterCard?: "summary_large_image"; | ||
} | ||
|
||
function Head({ | ||
children, | ||
pageTitle, | ||
description = "Easily share images and videos with others", | ||
url, | ||
image, | ||
video, | ||
ogType, | ||
twitterCard, | ||
}: HeadProps) { | ||
const siteTitle = pageTitle ? `${pageTitle} | Share Me` : "Share Me"; | ||
|
||
return ( | ||
<NextHead> | ||
<title>{siteTitle}</title> | ||
<meta property="og:title" content={siteTitle} /> | ||
<meta name="description" content={description} /> | ||
<meta property="og:url" content={url} /> | ||
<meta property="og:type" content={ogType} /> | ||
{image && ( | ||
<> | ||
<meta property="og:image" content={image} /> | ||
<meta property="twitter:image" content={image} /> | ||
</> | ||
)} | ||
{video && <meta property="og:video" content={video} />} | ||
{twitterCard && <meta property="twitter:card" content={twitterCard} />} | ||
<meta property="twitter:title" content={siteTitle} /> | ||
<meta property="twitter:description" content={description} /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
{children} | ||
</NextHead> | ||
); | ||
} | ||
|
||
export default Head; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.