import { Container } from "@/components/landing/container"; import { FadeIn } from "@/components/landing/fade-in"; import { MdxContent } from "@/components/landing/mdx-content"; // import { PageLinks } from "@/components/landing/page-links"; import { Avatar, AvatarImage } from "@/components/ui/avatar"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { authors } from "@/content/blog/authors"; import type { GetServerSideProps, Metadata } from "next"; import Link from "next/link"; import { notFound } from "next/navigation"; import { BLOG_PATH, getContentData, getFilePaths, getPost, getPostContent } from "@/lib/mdx-helper"; import service from "@/lib/http/service"; import { Header, NavBack, TimeP } from "@/components/header"; import { baseTitle, baseURL, keywordsRoot } from "@/lib/metadata"; import { useTranslation } from "react-i18next"; export const runtime = "nodejs"; type Props = { params: { locale: string, slug: string; title: string; description: string; authorName: string }; searchParams: { [key: string]: string | string[] | undefined }; }; export async function generateMetadata({ params }: Props): Promise { // export async function generateMetadata(ctx: any): Promise { // read route params // const { frontmatter } = await getPost(params.slug); // const { t, i18n } = useTranslation() const { serialized, frontmatter, headings } = await getPostContent(params.locale, params.slug); console.log("---generateMetadata---", headings) // const { // serialized, // frontmatter, // headings, // } = ctx if (!frontmatter) { return notFound(); } // const baseUrl = process.env.VERCEL_URL ? "https://jellyai.xyz" : "http://localhost:3000"; const baseUrl = process.env.VERCEL_URL ? process.env.VERCEL_URL : baseURL; const ogUrl = new URL("/og/blog", baseUrl); const author = authors[frontmatter.author]; ogUrl.searchParams.set("title", frontmatter.title ?? ""); // ogUrl.searchParams.set("author", author.name ?? ""); // if (author.image.src) { // ogUrl.searchParams.set("image", new URL(author.image.src, baseUrl).toString()); // } return { // title: { // default: 'JellyAI', // template: `${frontmatter.title} | JellyAI` // }, title: `${frontmatter.title}`, description: frontmatter.description, keywords: keywordsRoot(headings.text || ""), openGraph: { title: `${frontmatter.title} | ${baseTitle}`, description: frontmatter.description, // url: `https://unkey.dev/blog/${params.slug}`, type: "article", images: [ { url: ogUrl.toString(), width: 1200, height: 630, alt: frontmatter.title, }, ], // siteName: "unkey.dev", }, twitter: { card: "summary_large_image", title: `${frontmatter.title} | ${baseTitle}`, description: frontmatter.description, images: [ { url: ogUrl.toString(), width: 1200, height: 630, alt: frontmatter.title, }, ], // site: "@aigxion", // creator: "@aigxion", }, icons: { shortcut: "/favicon.png", }, }; } // export const generateStaticParams = async () => { // const posts = await getFilePaths(BLOG_PATH); // // Remove file extensions for page paths // posts.map((path) => path.replace(/\.mdx?$/, "")).map((slug) => ({ params: { slug } })); // return posts; // }; // export async function getStaticProps() { // const res = await fetch(`https://...`) // const projects = await res.json() // return { props: { projects } } // } // export default function Index({ projects }) { // return projects.map((project) =>
{project.name}
) // } // getServerSideProps generateStaticParams getStaticProps // export async function getStaticProps({ params }: { params: { slug: string } }) { // export async function getServerSideProps({ params }: { params: { slug: string } }) { // const { serialized, frontmatter, headings } = await getPostContent(params.slug); // // 使用 params.id 查询数据库获取数据 // // const post = await getPostById(params.id); // console.log("generateStaticParams", headings, params, params.slug) // return { // props: { // ...params, // serialized, // frontmatter, // headings // }, // }; // } const BlogArticleWrapper = async ({ params }: { params: { slug: string, locale: string, } }) => { // const BlogArticleWrapper = async (ctx: any) => { // console.log(ctx) // const { // serialized, // frontmatter, // headings, // } = ctx const { serialized, frontmatter, headings } = await getPostContent(params.locale, params.slug); // console.log(serialized, frontmatter, headings, params.slug) // console.log(params.slug) console.log("frontmatter", frontmatter) const defaultImage = "https://gimg3.baidu.com/search/src=http%3A%2F%2Fpics3.baidu.com%2Ffeed%2F4ec2d5628535e5dd7c7cdc23847e08e2cc1b62c4.jpeg%40f_auto%3Ftoken%3D38327d5cbefb2cd45af58f8d47c0a0b5&refer=http%3A%2F%2Fwww.baidu.com&app=2021&size=f360,240&n=0&g=0n&q=75&fmt=auto?sec=1710435600&t=eafc0a27ff3295bb5b0b9065fc33a523" return ( <>
Blog

>

{frontmatter.title}

{/*

All Blogs

*/} { frontmatter.tags && frontmatter.tags?.length > 0 && frontmatter.tags?.map((item, index) => { return

{item}

}) }
{/*

{} {t("JellyAI")}

*/}

{frontmatter.title}

{frontmatter.title}
); }; export default BlogArticleWrapper; // const BlogArticleWrapper_bak = async ({ params }: { params: { slug: string } }) => { // const { serialized, frontmatter, headings } = await getPost(params.slug); // console.log(serialized, frontmatter, headings, params.slug) // const author = authors[frontmatter.author]; // const moreArticles = await getContentData({ // contentPath: BLOG_PATH, // filepath: params.slug, // }); // return ( // <> // //
//
//

// {frontmatter.title} //

//

{frontmatter.description}

//
// //
//
//
//
// // // //
//
{author.name}
//
//
// { //
//

// Table of Contents //

// //
// {headings.map((heading) => { // return ( // // ); // })} //
// //
//
// } //
//
//
// //
//
// //
//

// Accelerate your API development //

//
// // Get started // // // Documentation // //
//
//
// App screenshot //
//
//
//
// {/* {moreArticles.length > 0 && ( // // )} */} // // ); // };