Skip to content

Commit

Permalink
⚡️ feat: metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehadianto committed Jul 30, 2024
1 parent 573fd98 commit 69e7730
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 4 deletions.
48 changes: 48 additions & 0 deletions common/components/PageHead/PageHead.tsx
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>
);
};
1 change: 1 addition & 0 deletions common/components/PageHead/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PageHead';
2 changes: 2 additions & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CoreLayout } from "@/common/components/CoreLayout";
import { PageHead } from "@/common/components/PageHead";
import { inter } from "@/common/fonts";

import type { AppProps } from "next/app";
Expand All @@ -12,6 +13,7 @@ export default function App({ Component, pageProps }: AppProps) {

return (
<>
<PageHead />
{/* This is required for fonts to work in Portal too */}
<style global jsx>{`
:root {
Expand Down
13 changes: 12 additions & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@ import { Html, Head, Main, NextScript } from "next/document";
export default function Document() {
return (
<Html lang="en">
<Head />
<Head>
<link
href="/andrehadianto.com/favicons/icon-dark.png"
media="(prefers-color-scheme: dark)"
rel="icon"
/>
<link
href="/andrehadianto.com/favicons/icon-light.png"
media="(prefers-color-scheme: light)"
rel="icon"
/>
</Head>
<body>
<Main />
<NextScript />
Expand Down
2 changes: 1 addition & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function Home() {
</motion.div>
<motion.div
{...fadeInMotion()}
className="bg-primary-default col-span-1 row-span-1 rounded-md"
className="col-span-1 row-span-1 rounded-md bg-primary-default"
>
<div className="flex h-full w-full flex-col items-center justify-center gap-2">
<Image
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
Binary file added public/favicons/icon-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/favicons/icon-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

0 comments on commit 69e7730

Please sign in to comment.