Skip to content

Commit

Permalink
Merge pull request #66 from shandianchengzi/patch-2
Browse files Browse the repository at this point in the history
RankList: 排行榜添加 编辑部业绩 与 用心选题.
  • Loading branch information
mudongliang committed May 5, 2024
2 parents cb8578b + b74bc14 commit 14537cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions pages/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const RANK_LIST: {
}[] = [
{ status: "translator", text: "翻译王者", tabText: "翻译王者", color: "bg-green-500" },
{ status: "proofreader", text: "校验大佬", tabText: "校验大佬", color: "bg-purple-500" },
{ status: "collector", text: "用心选题", tabText: "用心选题", color: "bg-red-500" },
{ status: "publisher", text: "编辑部业绩", tabText: "编辑部业绩", color: "bg-blue-500" },
];

export const SOCIALS: SocialObjects = [
Expand Down
30 changes: 18 additions & 12 deletions pages/src/layouts/RankLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,25 @@ function getRank() {
let oneRank = value;
// for each post, update the count for each tag
for (let i = 0; i < paginatedPosts.length; i++) {
const { data }: { data: {status: string, translator: string, proofreader: string} } = paginatedPosts[i];
const { translator, proofreader } = data;
const needToRank : {[key: string]: {expect_status: string}} = {
"collector": { "expect_status": ""},
"translator": { "expect_status": "translating"},
"proofreader": { "expect_status": "proofreading"},
"publisher": { "expect_status": ""}
};
// key not in needToRank, skip
if (!needToRank.hasOwnProperty(key)) {
continue;
}
// get data from post
const {data}: {data: any} = paginatedPosts[i];
// get the name from post
let name = data[key];
// set the count and avatar for each tag
let rankPerson = "";
if (key === "translator" && translator) {
// need the status not be translating
if (data.status != "translating"){
rankPerson = translator;
}
}
else if (key === "proofreader" && proofreader) {
// need the status not be proofreading
if (data.status != "proofreading"){
rankPerson = proofreader;
if (name) {
if (data.status != needToRank[key].expect_status) {
rankPerson = name;
}
}
// remove 'HCTT' and '' from the rank list
Expand Down Expand Up @@ -124,6 +129,7 @@ async function getAllAvatar() {
max-width: 48rem;
padding-right: 1rem;
width: 100%;
flex-wrap: wrap;
}

#main-content > section {
Expand Down

0 comments on commit 14537cf

Please sign in to comment.