update: 添加二级分类期刊列表 page 的 title、description

feature/qrcode
mackt 2 months ago
parent 6c8a66ea21
commit f065c18dc3

@ -5,11 +5,23 @@ import { Category, JournalRecommendList, JournalItem, Pagination, RedirectCheck,
import { apiSearchCategoryList, apiGetJournalRecommendWithCollect, apiJournalList, apiGetTags } from '@/services';
export async function generateMetadata({ params: { category } }: { params: { category?: string } }) {
if (category && category !== 'all') {
const categoryList = await getCategoryList();
const categoryInfo: Category | undefined = categoryList.find((item: Category) => item.nameEn === category);
return { title: categoryInfo?.nameCh, description: categoryInfo?.description };
}
/**
*
* 1.
* 2.
* 3.
* */
if (category === 'all' || !category) return;
const categoryList = await getCategoryList();
const categoryInfo: Category | undefined = categoryList.find((item: Category) => item.nameEn === category); // 一级分类
const tagList = await apiGetTagList();
const tagInfo: TagInfo | undefined = tagList.find((item: TagInfo) => item.engName === category); // 二级分类
const title = categoryInfo?.nameCh || tagInfo?.name;
const description =
categoryInfo?.description ||
'雀乐是由一群喜欢并热爱独立音乐的人共同创建的,我们致力于传播来自世界各地的独立音乐。我们秉着音乐里独立自主的精神表达内核,希望把雀乐建设成为泛华语地区最好的独立音乐传播平台。';
return { title, description };
}
const apiGetTagList = async () => {

Loading…
Cancel
Save