Skip to content

Commit

Permalink
fix: opengraph stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhozhr10 committed Jun 1, 2024
1 parent 84ce34c commit b97f4d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/app/posts/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ export function generateMetadata({ params }: Props): Metadata {
}
return {
title: `${params.path.join("/")} Posts :: Ridho Azhar`,
metadataBase: new URL(baseURL),
robots: { follow: true, index: true },
openGraph: {
url: `/posts/${params.path.join("/")}`,
title: `${params.path.join("/")} Posts :: Ridho Azhar`,
images: `/img/smug-ico.png`,
type: "website",
},
};
}

Expand All @@ -100,15 +108,15 @@ export function generateMetadata({ params }: Props): Metadata {
const post = data.post;
const title = `${post.title} :: Ridho Azhar`;
return {
metadataBase: new URL(`${baseURL}/posts/${post.path.join("/")}`),
metadataBase: new URL(baseURL),
title,
description: post.description,
robots: { follow: true, index: true },
openGraph: {
title,
url: `${baseURL}/posts/${post.path.join("/")}`,
description: post.description,
images: [`${baseURL}${post.ogImage.url}`],
images: [post.ogImage.url],
type: "article",
authors: "ridhozhr10.github.io",
publishedTime: post.created_at,
Expand Down
8 changes: 8 additions & 0 deletions src/app/tags/[tag]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import dayjs from "dayjs";
import "@/app/posts/style.scss";
import { Metadata } from "next";
import { BiTagAlt } from "react-icons/bi";
import { baseURL } from "@/constants";

type Props = {
params: {
Expand Down Expand Up @@ -59,8 +60,15 @@ export function generateMetadata({ params }: Props): Metadata {
const title = `#${params.tag} :: Ridho Azhar`;

return {
metadataBase: new URL(baseURL),
title,
robots: { follow: true, index: true },
openGraph: {
title: `title`,
url: `/tags/${params.tag}`,
images: `/img/smug-ico.png`,
type: "website",
},
};
}
export function generateStaticParams() {
Expand Down
6 changes: 3 additions & 3 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ self proclaimed friendly person (trust me),
black coffee enjoyer`;
export const baseMetadata = (path: string, titlePrefix?: string): Metadata => {
return {
metadataBase: new URL(`${baseURL}${path ? "/" : ""}${path}`),
metadataBase: new URL(`${baseURL}`),
title: `${titlePrefix || ""}${titlePrefix ? " :: " : ""}${title}`,
description,
openGraph: {
title: `${titlePrefix || ""}${titlePrefix ? " :: " : ""}${title}`,
url: `${baseURL}${path ? "/" : ""}${path}`,
url: `${path ? "/" : ""}${path}`,
description: description,
images: `${baseURL}/img/smug-ico.png`,
images: `/img/smug-ico.png`,
type: "website",
},
};
Expand Down

0 comments on commit b97f4d5

Please sign in to comment.