Files
yphsalumni.org/app/pages/news/[slug].vue
xiaomai a28bb3a54d feat(news): enhance SEO meta tags and add clarification article
- Update news detail page to use `useSeoMeta` for comprehensive Open Graph and Twitter Card support.
- Implement logic to prioritize `ogImage` and `seoTitle` with fallbacks to standard fields.
- Add new content article clarifying the distinction between the Alumni Association and the Alumni Liaison Office.
- Add documentation drafts for onboarding messages and announcement design.
2025-11-28 11:54:11 +08:00

61 lines
1.6 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div>
<section class="py-20 px-4">
<div class="container mx-auto max-w-6xl">
<!-- 内容渲染器 -->
<div class="prose prose-invert prose-lg max-w-none">
<ContentRenderer :value="n ?? {}">
<template #empty>
<div class="text-center py-12">
<p class="text-gray-400 text-xl">内容加载中...</p>
</div>
</template>
</ContentRenderer>
</div>
</div>
</section>
</div>
</template>
<script lang="ts" setup>
const route = useRoute();
const { data: n } = await useAsyncData("new-detail", () =>
queryCollection("news").path(`/news/${route.params.slug}`).first()
);
if (n.value) {
// 1. 确定图片:优先用 ogImage没有就用 cover
const shareImage = n.value.ogImage || n.value.cover;
// 2. 确定标题和描述:优先用 seoTitle没有就用 title
const shareTitle = n.value.seoTitle || n.value.title;
const shareDesc = n.value.seoDescription || n.value.description;
// 3. 注入 SEO
useSeoMeta({
// 基础
title: shareTitle,
description: shareDesc,
// Open Graph (Facebook / WhatsApp)
ogTitle: shareTitle,
ogDescription: shareDesc,
ogImage: shareImage,
ogType: "article",
// Twitter Card
twitterCard: "summary_large_image",
twitterTitle: shareTitle,
twitterDescription: shareDesc,
twitterImage: shareImage,
});
// 如果你用了 nuxt-og-image 模块生成动态图
if (shareImage) {
defineOgImage({ url: shareImage });
}
}
</script>
<style></style>