Initial Commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import type { FriendLink, FriendsPageConfig } from "../types/friendsConfig";
|
||||
|
||||
// 可以在src/content/spec/friends.md中编写友链页面下方的自定义内容
|
||||
|
||||
// 友链页面配置
|
||||
export const friendsPageConfig: FriendsPageConfig = {
|
||||
// 页面标题,如果留空则使用 i18n 中的翻译
|
||||
title: "",
|
||||
|
||||
// 页面描述文本,如果留空则使用 i18n 中的翻译
|
||||
description: "",
|
||||
|
||||
// 是否显示底部自定义内容(friends.mdx 中的内容)
|
||||
showCustomContent: true,
|
||||
|
||||
// 是否显示评论区,需要先在commentConfig.ts启用评论系统
|
||||
showComment: false,
|
||||
|
||||
// 是否开启随机排序配置,如果开启,就会忽略权重,构建时进行一次随机排序
|
||||
randomizeSort: false,
|
||||
};
|
||||
|
||||
// 友链配置
|
||||
export const friendsConfig: FriendLink[] = [
|
||||
{
|
||||
title: "狼与凤梨田",
|
||||
imgurl: "https://avatars.githubusercontent.com/u/91077200?v=4",
|
||||
desc: "初雪 · 冰",
|
||||
siteurl: "https://wolf.snowlyicewolf.club/",
|
||||
tags: ["Blog"],
|
||||
weight: 10, // 权重,数字越大排序越靠前
|
||||
enabled: true, // 是否启用
|
||||
},
|
||||
{
|
||||
title: "TheWind's Blog",
|
||||
imgurl: "https://q.qlogo.cn/headimg_dl?dst_uin=2011332114&spec=640&img_type=png",
|
||||
desc: "The Wind",
|
||||
siteurl: "https://blog.thewinds.top/",
|
||||
tags: ["Blog"],
|
||||
weight: 9,
|
||||
enabled: true,
|
||||
},
|
||||
];
|
||||
|
||||
// 获取启用的友链并进行排序
|
||||
export const getEnabledFriends = (): FriendLink[] => {
|
||||
const friends = friendsConfig.filter((friend) => friend.enabled);
|
||||
|
||||
if (friendsPageConfig.randomizeSort) {
|
||||
return friends.sort(() => Math.random() - 0.5);
|
||||
}
|
||||
|
||||
return friends.sort((a, b) => b.weight - a.weight);
|
||||
};
|
||||
Reference in New Issue
Block a user