This commit is contained in:
hailin 2025-03-13 21:42:07 +08:00
parent 7ade0e113b
commit df7b59f241
1 changed files with 1 additions and 76 deletions

View File

@ -24,48 +24,26 @@ type Props = {
};
export async function generateMetadata({ params }: Props): Promise<Metadata> {
// export async function generateMetadata(ctx: any): Promise<Metadata> {
// 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
console.log("---------------------------generateMetadata-----------------------------", headings)
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: [
{
@ -75,7 +53,6 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
alt: frontmatter.title,
},
],
// siteName: "unkey.dev",
},
twitter: {
card: "summary_large_image",
@ -89,8 +66,6 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
alt: frontmatter.title,
},
],
// site: "@aigxion",
// creator: "@aigxion",
},
icons: {
shortcut: "/favicon.png",
@ -98,64 +73,14 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
};
}
// 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) => <div>{project.name}</div>)
// }
// 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 (
<>
<NavBack />