import { NotionAPI } from "notion-client"; import Image from "next/image"; import { getPageImageUrls, getPageProperty, getPageTitle } from "notion-utils"; import "@/components/notion/notion.scss"; import "react-notion-x/src/styles.css"; import "prismjs/themes/prism-tomorrow.css"; import { BackgroundGradentProvider } from "@/components/gradient-provider"; import GrainProvider from "@/components/grain"; import { Footer } from "../Footer"; import { Connect } from "../Connect"; import { Home, MessageCircleIcon } from "lucide-react"; import Link from "next/link"; import { NRenderer } from "@/components/notion/renderer"; import { Metadata, ResolvingMetadata } from "next"; import Comments, { Reactions } from "@/components/comments"; import { Stats } from "./stats"; export const revalidate = 100; type Props = { searchParams: { id?: string }; }; export async function generateMetadata( { searchParams }: Props, parent: ResolvingMetadata, ): Promise { const notion = new NotionAPI(); const recordMap = await notion.getPage(searchParams.id!); const title = getPageTitle(recordMap); const page_block = Object.values(recordMap.block)[0].value; const description = getPageProperty("description", page_block, recordMap); const author = getPageProperty("author", page_block, recordMap); const github_username = getPageProperty("github", page_block, recordMap); const images = getPageImageUrls(recordMap, { mapImageUrl: (url) => url }); const params = new URLSearchParams({ title: title.toString(), description: description.toString(), author: author.toString(), images: images[0], github_username: github_username.toString(), }); const image_origin_url = process.env.NODE_ENV !== "development" ? "https://raj.how" : "http://localhost:3000"; const og_image_url = new URL("/api/og", image_origin_url); og_image_url.search = params.toString(); return { title: title, description: "Written by raj", openGraph: { images: [og_image_url.toString()], }, twitter: { images: [og_image_url.toString()], }, }; } export default async function Story({ searchParams, }: { searchParams: { id?: string }; }) { if (!searchParams.id) return null; const notion = new NotionAPI(); const recordMap = await notion.getPage(searchParams.id); const title = getPageTitle(recordMap); const images = getPageImageUrls(recordMap, { mapImageUrl: (url) => url }); const repo = process.env.COMMENTS_REPO; const repoId = process.env.COMMENTS_REPO_ID; const category = process.env.COMMENTS_CATEGORY; const categoryId = process.env.COMMENTS_CATEGORY_ID; console.log(repo, repoId, category, categoryId); return (
{title}

{title}

{repo && repoId && category && categoryId ? ( ) : null}
{repo && repoId && category && categoryId ? ( ) : null}
); }