Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Add blog metadata

Richie McIlroy3b18e74144d5
diff --git a/apps/web/app/updates/[slug]/page.tsx b/apps/web/app/updates/[slug]/page.tsx
index 9d765e773..c003379b8 100644
--- a/apps/web/app/updates/[slug]/page.tsx
+++ b/apps/web/app/updates/[slug]/page.tsx
@@ -1,11 +1,9 @@
-import { Metadata } from "next";
import { notFound } from "next/navigation";
-import { UpdatePage } from "../_components/UpdatePage";
import Image from "next/image";
-import Link from "next/link";
import { format, parseISO } from "date-fns";
import { MDXRemote } from "next-mdx-remote/rsc";
import { getBlogPosts } from "@/utils/updates";
+import type { Metadata } from "next";
interface PostProps {
params: {
@@ -13,12 +11,49 @@ interface PostProps {
};
}
+export async function generateMetadata({
+ params,
+}: PostProps): Promise<Metadata | undefined> {
+ let post = getBlogPosts().find((post) => post.slug === params.slug);
+ if (!post) {
+ return;
+ }
+
+ let {
+ title,
+ publishedAt: publishedTime,
+ summary: description,
+ image,
+ } = post.metadata;
+ let ogImage = `${process.env.NEXT_PUBLIC_URL}${image}`;
+
+ return {
+ title,
+ description,
+ openGraph: {
+ title,
+ description,
+ type: "article",
+ publishedTime,
+ url: `${process.env.NEXT_PUBLIC_URL}/updates/${post.slug}`,
+ images: [
+ {
+ url: ogImage,
+ },
+ ],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title,
+ description,
+ images: [ogImage],
+ },
+ };
+}
+
export default async function PostPage({ params }: PostProps) {
const post = getBlogPosts().find((post) => post.slug === params.slug);
- console.log(post);
- console.log(params);
-
if (!post) {
notFound();
}
diff --git a/apps/web/components/Navbar.tsx b/apps/web/components/Navbar.tsx
index c22919eeb..bd0bfbaf1 100644
--- a/apps/web/components/Navbar.tsx
+++ b/apps/web/components/Navbar.tsx
@@ -23,8 +23,6 @@ export const Navbar = ({ auth }: { auth: boolean }) => {
const isHomePage = pathname === "/";
const [showMobileMenu, setShowMobileMenu] = useState(false);
- console.log("params: ", ref);
-
if (
pathname === "/login" ||
pathname.includes("/dashboard") ||