4e21ca937a
Deploy Documentation / deploy (push) Has been cancelled
Canary / Prepare Version (push) Has been cancelled
Canary / build-cli (push) Has been cancelled
Canary / Upload Install Script (push) Has been cancelled
Canary / bundle-desktop (push) Has been cancelled
Canary / bundle-desktop-intel (push) Has been cancelled
Canary / bundle-desktop-linux (push) Has been cancelled
Canary / bundle-desktop-windows (push) Has been cancelled
Canary / bundle-desktop-windows-cuda (push) Has been cancelled
Canary / Release (push) Has been cancelled
Unused Dependencies / machete (push) Has been cancelled
CI / changes (push) Has been cancelled
CI / Check Rust Code Format (push) Has been cancelled
CI / Build and Test Rust Project (push) Has been cancelled
CI / Build Rust Project on Windows (push) Has been cancelled
CI / Check MSRV (push) Has been cancelled
CI / Lint Rust Code (push) Has been cancelled
CI / Check Generated Schemas are Up-to-Date (push) Has been cancelled
CI / Test and Lint Electron Desktop App (push) Has been cancelled
CI / H5 Plaza Tests and Build (push) Has been cancelled
Live Provider Tests / check-fork (push) Has been cancelled
Live Provider Tests / changes (push) Has been cancelled
Live Provider Tests / Build Binary (push) Has been cancelled
Live Provider Tests / Smoke Tests (push) Has been cancelled
Live Provider Tests / Smoke Tests (Code Execution) (push) Has been cancelled
Live Provider Tests / Compaction Tests (push) Has been cancelled
Live Provider Tests / goose server HTTP integration tests (push) Has been cancelled
Publish Ask AI Bot Docker Image / docker (push) Has been cancelled
Publish Docker Image / docker (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Fork goose with custom MCP widgets, platform extensions (aider, git, web, search), MindSpace H5 backend/frontend, Plaza/Ops UIs, and deploy scripts for tkmind.cn. Co-authored-by: Cursor <cursoragent@cursor.com>
181 lines
5.3 KiB
TypeScript
181 lines
5.3 KiB
TypeScript
import type { Metadata } from 'next';
|
|
import type { PlazaPost, PlazaUserProfile } from '@/types/plaza';
|
|
import { plazaPath, siteOrigin } from '@/lib/site';
|
|
|
|
const DEFAULT_OG = `${siteOrigin()}/plaza-og.png`;
|
|
|
|
function postOgImage(post: PlazaPost): string {
|
|
if (post.cover_url) return post.cover_url;
|
|
return `${siteOrigin()}${plazaPath(`p/${post.id}/opengraph-image`)}`;
|
|
}
|
|
|
|
export function homeMetadata(): Metadata {
|
|
const url = `${siteOrigin()}${plazaPath()}`;
|
|
return {
|
|
title: 'Plaza - 发现 AI 创作的精彩内容',
|
|
description: '浏览来自全球用户用 MindSpace 创作的报告、作品和页面',
|
|
openGraph: {
|
|
type: 'website',
|
|
title: 'Plaza - 发现 AI 创作的精彩内容',
|
|
description: '浏览来自全球用户用 MindSpace 创作的报告、作品和页面',
|
|
url,
|
|
siteName: 'MindSpace Plaza',
|
|
images: [{ url: DEFAULT_OG, width: 1200, height: 630 }],
|
|
},
|
|
alternates: { canonical: url },
|
|
robots: { index: true, follow: true },
|
|
};
|
|
}
|
|
|
|
export function categoryMetadata(name: string, slug: string, description?: string): Metadata {
|
|
const url = `${siteOrigin()}${plazaPath(`cat/${slug}`)}`;
|
|
return {
|
|
title: `${name} - Plaza | MindSpace`,
|
|
description: description || `浏览 Plaza「${name}」分类下的 AI 创作内容`,
|
|
openGraph: {
|
|
type: 'website',
|
|
title: `${name} - Plaza`,
|
|
description: description || `Plaza「${name}」分类`,
|
|
url,
|
|
siteName: 'MindSpace Plaza',
|
|
images: [{ url: DEFAULT_OG, width: 1200, height: 630 }],
|
|
},
|
|
alternates: { canonical: url },
|
|
robots: { index: true, follow: true },
|
|
};
|
|
}
|
|
|
|
export function postMetadata(post: PlazaPost): Metadata {
|
|
const url = `${siteOrigin()}${plazaPath(`p/${post.id}`)}`;
|
|
const image = postOgImage(post);
|
|
const description =
|
|
post.summary || `${post.author.display_name} 用 MindSpace 创作的作品`;
|
|
|
|
return {
|
|
title: `${post.title} - Plaza | MindSpace`,
|
|
description,
|
|
keywords: post.tags.join(', '),
|
|
openGraph: {
|
|
title: post.title,
|
|
description,
|
|
url,
|
|
siteName: 'MindSpace Plaza',
|
|
images: [{ url: image, width: 1200, height: 630, alt: post.title }],
|
|
type: 'article',
|
|
publishedTime: post.published_at,
|
|
authors: [`${siteOrigin()}/u/${post.author.slug}`],
|
|
tags: post.tags,
|
|
},
|
|
twitter: {
|
|
card: 'summary_large_image',
|
|
title: post.title,
|
|
description,
|
|
images: [image],
|
|
creator: `@${post.author.slug}`,
|
|
},
|
|
alternates: { canonical: url },
|
|
robots: { index: true, follow: true },
|
|
};
|
|
}
|
|
|
|
export function postJsonLd(post: PlazaPost) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Article',
|
|
headline: post.title,
|
|
description: post.summary,
|
|
image: post.cover_url || postOgImage(post),
|
|
datePublished: post.published_at,
|
|
author: {
|
|
'@type': 'Person',
|
|
name: post.author.display_name,
|
|
url: `${siteOrigin()}/u/${post.author.slug}`,
|
|
},
|
|
publisher: {
|
|
'@type': 'Organization',
|
|
name: 'MindSpace',
|
|
logo: {
|
|
'@type': 'ImageObject',
|
|
url: `${siteOrigin()}/logo.png`,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export function userMetadata(user: PlazaUserProfile): Metadata {
|
|
const url = `${siteOrigin()}/u/${user.slug}`;
|
|
const description =
|
|
user.bio || `${user.display_name} 在 MindSpace Plaza 发布了 ${user.stats.post_count} 篇作品`;
|
|
const image = user.avatar_url || DEFAULT_OG;
|
|
|
|
return {
|
|
title: `${user.display_name} (@${user.slug}) - Plaza | MindSpace`,
|
|
description,
|
|
openGraph: {
|
|
type: 'profile',
|
|
title: user.display_name,
|
|
description,
|
|
url,
|
|
siteName: 'MindSpace Plaza',
|
|
images: user.avatar_url
|
|
? [{ url: image, width: 400, height: 400, alt: user.display_name }]
|
|
: [{ url: DEFAULT_OG, width: 1200, height: 630 }],
|
|
},
|
|
twitter: {
|
|
card: user.avatar_url ? 'summary' : 'summary_large_image',
|
|
title: user.display_name,
|
|
description,
|
|
images: [image],
|
|
},
|
|
alternates: { canonical: url },
|
|
robots: { index: true, follow: true },
|
|
};
|
|
}
|
|
|
|
export function userJsonLd(user: PlazaUserProfile) {
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'ProfilePage',
|
|
name: user.display_name,
|
|
description: user.bio || `${user.display_name} 的 MindSpace Plaza 主页`,
|
|
url: `${siteOrigin()}/u/${user.slug}`,
|
|
mainEntity: {
|
|
'@type': 'Person',
|
|
name: user.display_name,
|
|
alternateName: user.slug,
|
|
url: `${siteOrigin()}/u/${user.slug}`,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function homeJsonLd() {
|
|
const url = `${siteOrigin()}${plazaPath()}`;
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'WebSite',
|
|
name: 'MindSpace Plaza',
|
|
url,
|
|
description: '浏览来自全球用户用 MindSpace 创作的报告、作品和页面',
|
|
publisher: {
|
|
'@type': 'Organization',
|
|
name: 'MindSpace',
|
|
},
|
|
};
|
|
}
|
|
|
|
export function categoryJsonLd(name: string, slug: string, description?: string) {
|
|
const url = `${siteOrigin()}${plazaPath(`cat/${slug}`)}`;
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'CollectionPage',
|
|
name: `${name} - Plaza`,
|
|
description: description || `Plaza「${name}」分类下的 AI 创作内容`,
|
|
url,
|
|
isPartOf: {
|
|
'@type': 'WebSite',
|
|
name: 'MindSpace Plaza',
|
|
url: `${siteOrigin()}${plazaPath()}`,
|
|
},
|
|
};
|
|
}
|