-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
573fd98
commit 69e7730
Showing
10 changed files
with
64 additions
and
4 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,48 @@ | ||
import Head from "next/head"; | ||
import { PropsWithChildren, useMemo } from "react"; | ||
|
||
export interface PageHeadProps { | ||
name?: string; | ||
description?: string; | ||
removeTitleAppend?: boolean; | ||
titleAppendSeparator?: string; | ||
} | ||
|
||
const appName = "Andre Hadianto Lesmana"; | ||
|
||
export const PageHead = ({ | ||
name, | ||
description, | ||
removeTitleAppend = false, | ||
titleAppendSeparator = "|", | ||
children, | ||
}: PropsWithChildren<PageHeadProps>) => { | ||
const pageName = useMemo(() => { | ||
if (!removeTitleAppend) { | ||
return name ? `${name} ${titleAppendSeparator} ${appName}` : appName; | ||
} | ||
return name ?? appName; | ||
}, [name, removeTitleAppend, titleAppendSeparator]); | ||
|
||
const pageDesc = | ||
description ?? | ||
"Welcome to my page! Check out my projects and contact me if you want to work together!"; | ||
|
||
return ( | ||
<Head> | ||
<meta charSet="utf-8" /> | ||
<meta content="width=device-width, initial-scale=1.0" name="viewport" /> | ||
<title>{pageName}</title> | ||
<meta content={pageDesc} name="description" /> | ||
<meta content={pageName} name="og:title" /> | ||
<meta content={pageDesc} name="og:description" /> | ||
<meta content={appName} property="og:site_name" /> | ||
<meta content="en" property="og:locale" /> | ||
<meta content="website" property="og:type" /> | ||
{/* Note: using <ThemeProvider themeColor> for this in _app */} | ||
{/* <meta content="var(--theme-color)" name="theme-color" /> */} | ||
|
||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './PageHead'; |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.