diff --git a/community/team.mdx b/community/team.mdx index 3b3a14843..3f3dbdfc3 100644 --- a/community/team.mdx +++ b/community/team.mdx @@ -20,7 +20,7 @@ The PMC is also responsible for voting on releases of their project, to ensure t UserData[0].users.map(u => { return (
- +
{u.name}
{u.role}
@@ -40,7 +40,7 @@ Committers have read-write access to the code repository, signed the CLA, and us UserData[1].users.map(u => { return (
- +
{u.name}
{u.role}
diff --git a/scripts/contributor.js b/scripts/contributor.js index 91e71e375..fd9914198 100644 --- a/scripts/contributor.js +++ b/scripts/contributor.js @@ -5,6 +5,7 @@ var path = require('path'); var TeamJson = require('../static/data/team.json'); var outputFile = path.resolve(__dirname, '../static/data/team.json'); +var teamAvatarDir = path.resolve(__dirname, '../static/img/team'); // ignore PMC and committers members var ignoreList = []; @@ -94,4 +95,64 @@ function fetchPagedContributors(url, index, page, currentResults) { }); } -fetchContributors(); +saveAvatars('pmc'); +saveAvatars('committer'); + +// 根据 MIME 类型获取文件扩展名 +function getExtensionFromMimeType(mimeType) { + var mimeToExtension = { + 'image/jpeg': 'jpg', + 'image/png': 'png', + 'image/gif': 'gif', + 'image/webp': 'webp', + 'image/svg+xml': 'svg', + }; + + return mimeToExtension[mimeType] || 'jpg'; +} + +// save avatars +async function saveAvatars(type) { + const dataType = TeamJson.find((item) => item.type === type); + const users = dataType.users; + for (const user of users) { + try { + const avatarUrl = user.avatar; + + const response = await fetch(avatarUrl); + if (!response.ok) { + throw new Error(`Failed to fetch ${avatarUrl}: ${response.statusText}`); + } + const contentType = response.headers.get('content-type'); + // According to Content-Type to get extension + const extension = getExtensionFromMimeType(contentType); + + const avatarName = `${user.name}.${extension}`; + const savePath = path.join(teamAvatarDir, avatarName); + const arrayBuffer = await response.arrayBuffer(); + const buffer = Buffer.from(arrayBuffer); + fs.writeFileSync(savePath, buffer); + // 更新 avatar2 字段为相对路径 + user.avatar_local = `/img/team/${avatarName}`; + + console.log(`Saved avatar for ${user.name} to ${savePath}`); + } catch (error) { + console.error(`Failed to save avatar for ${user.name}:`, error.message); + } + } + TeamJson = TeamJson.map((item) => { + if (item.type === type) { + return { + ...item, + users, + }; + } + return item; + }); + fs.writeFileSync(outputFile, JSON.stringify(TeamJson, null, 2)); +} + +saveAvatars('pmc'); +saveAvatars('committer'); + +// fetchContributors(); diff --git a/static/data/team.json b/static/data/team.json index e2c14d30e..1f38eceb6 100644 --- a/static/data/team.json +++ b/static/data/team.json @@ -7,85 +7,99 @@ "name": "chrisdutz", "avatar": "https://avatars.githubusercontent.com/u/651105", "github": "https://github.com/chrisdutz", - "role": "Mentor" + "role": "Mentor", + "avatar_local": "/img/team/chrisdutz.jpg" }, { "name": "fenbox", "avatar": "https://avatars.githubusercontent.com/u/360618", "github": "https://github.com/fenbox", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/fenbox.png" }, { "name": "jiangbonadia", "avatar": "https://avatars.githubusercontent.com/u/1227386", "github": "https://github.com/jiangbonadia", - "role": "DevRel" + "role": "DevRel", + "avatar_local": "/img/team/jiangbonadia.jpg" }, { "name": "joyqi", "avatar": "https://avatars.githubusercontent.com/u/59437", "github": "https://github.com/joyqi", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/joyqi.png" }, { "name": "justinmclean", "avatar": "https://avatars.githubusercontent.com/u/144504", "github": "https://github.com/justinmclean", - "role": "Mentor" + "role": "Mentor", + "avatar_local": "/img/team/justinmclean.jpg" }, { "name": "kumfo", "avatar": "https://avatars.githubusercontent.com/u/7692591", "github": "https://github.com/kumfo", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/kumfo.jpg" }, { "name": "LinkinStars", "avatar": "https://avatars.githubusercontent.com/u/19712692", "github": "https://github.com/LinkinStars", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/LinkinStars.jpg" }, { "name": "mingcheng", "avatar": "https://avatars.githubusercontent.com/u/21816", "github": "https://github.com/mingcheng", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/mingcheng.png" }, { "name": "PrimmaAnna", "avatar": "https://avatars.githubusercontent.com/u/131739771", "github": "https://github.com/PrimmaAnna", - "role": "DevRel" + "role": "DevRel", + "avatar_local": "/img/team/PrimmaAnna.png" }, { "name": "robinv8", "avatar": "https://avatars.githubusercontent.com/u/12277531", "github": "https://github.com/robinv8", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/robinv8.jpg" }, { "name": "shuashuai", "avatar": "https://avatars.githubusercontent.com/u/30591202", "github": "https://github.com/shuashuai", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/shuashuai.jpg" }, { "name": "sy-records", "github": "https://github.com/sy-records", "avatar": "https://avatars.githubusercontent.com/u/33931153?v=4", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/sy-records.jpg" }, { "name": "tisonkun", "avatar": "https://avatars.githubusercontent.com/u/18818196", "github": "https://github.com/tisonkun", - "role": "Mentor" + "role": "Mentor", + "avatar_local": "/img/team/tisonkun.jpg" }, { "name": "WillemJiang", "avatar": "https://avatars.githubusercontent.com/u/219644", "github": "https://github.com/WillemJiang", - "role": "Mentor" + "role": "Mentor", + "avatar_local": "/img/team/WillemJiang.jpg" } ] }, @@ -97,25 +111,29 @@ "name": "aichy126", "avatar": "https://avatars.githubusercontent.com/u/16996097", "github": "https://github.com/aichy126", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/aichy126.jpg" }, { "name": "haitaojarvis", "avatar": "https://avatars.githubusercontent.com/u/344142", "github": "https://github.com/haitaojarvis", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/haitaojarvis.jpg" }, { "name": "hgaol", "avatar": "https://avatars.githubusercontent.com/u/11908658?v=4", "github": "https://github.com/hgaol", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/hgaol.jpg" }, { "name": "zahash", "github": "https://github.com/zahash", "avatar": "https://avatars.githubusercontent.com/u/36153955?v=4", - "role": "Developer" + "role": "Developer", + "avatar_local": "/img/team/zahash.png" } ] }, diff --git a/static/img/team/LinkinStars.jpg b/static/img/team/LinkinStars.jpg new file mode 100644 index 000000000..bb22126ec Binary files /dev/null and b/static/img/team/LinkinStars.jpg differ diff --git a/static/img/team/PrimmaAnna.png b/static/img/team/PrimmaAnna.png new file mode 100644 index 000000000..9c5b35bad Binary files /dev/null and b/static/img/team/PrimmaAnna.png differ diff --git a/static/img/team/WillemJiang.jpg b/static/img/team/WillemJiang.jpg new file mode 100644 index 000000000..230b1c9d4 Binary files /dev/null and b/static/img/team/WillemJiang.jpg differ diff --git a/static/img/team/aichy126.jpg b/static/img/team/aichy126.jpg new file mode 100644 index 000000000..77a4379e0 Binary files /dev/null and b/static/img/team/aichy126.jpg differ diff --git a/static/img/team/chrisdutz.jpg b/static/img/team/chrisdutz.jpg new file mode 100644 index 000000000..f5f593f79 Binary files /dev/null and b/static/img/team/chrisdutz.jpg differ diff --git a/static/img/team/fenbox.png b/static/img/team/fenbox.png new file mode 100644 index 000000000..e753dd3d3 Binary files /dev/null and b/static/img/team/fenbox.png differ diff --git a/static/img/team/haitaojarvis.jpg b/static/img/team/haitaojarvis.jpg new file mode 100644 index 000000000..e5ec7f03c Binary files /dev/null and b/static/img/team/haitaojarvis.jpg differ diff --git a/static/img/team/hgaol.jpg b/static/img/team/hgaol.jpg new file mode 100644 index 000000000..13414ce89 Binary files /dev/null and b/static/img/team/hgaol.jpg differ diff --git a/static/img/team/jiangbonadia.jpg b/static/img/team/jiangbonadia.jpg new file mode 100644 index 000000000..ec930cdb4 Binary files /dev/null and b/static/img/team/jiangbonadia.jpg differ diff --git a/static/img/team/joyqi.png b/static/img/team/joyqi.png new file mode 100644 index 000000000..5b82a80eb Binary files /dev/null and b/static/img/team/joyqi.png differ diff --git a/static/img/team/justinmclean.jpg b/static/img/team/justinmclean.jpg new file mode 100644 index 000000000..a7e3234d9 Binary files /dev/null and b/static/img/team/justinmclean.jpg differ diff --git a/static/img/team/kumfo.jpg b/static/img/team/kumfo.jpg new file mode 100644 index 000000000..87d36499c Binary files /dev/null and b/static/img/team/kumfo.jpg differ diff --git a/static/img/team/mingcheng.png b/static/img/team/mingcheng.png new file mode 100644 index 000000000..c16b1d1bd Binary files /dev/null and b/static/img/team/mingcheng.png differ diff --git a/static/img/team/robinv8.jpg b/static/img/team/robinv8.jpg new file mode 100644 index 000000000..615d17979 Binary files /dev/null and b/static/img/team/robinv8.jpg differ diff --git a/static/img/team/shuashuai.jpg b/static/img/team/shuashuai.jpg new file mode 100644 index 000000000..2d15bf0d5 Binary files /dev/null and b/static/img/team/shuashuai.jpg differ diff --git a/static/img/team/sy-records.jpg b/static/img/team/sy-records.jpg new file mode 100644 index 000000000..295b94b07 Binary files /dev/null and b/static/img/team/sy-records.jpg differ diff --git a/static/img/team/tisonkun.jpg b/static/img/team/tisonkun.jpg new file mode 100644 index 000000000..36b1f71a0 Binary files /dev/null and b/static/img/team/tisonkun.jpg differ diff --git a/static/img/team/zahash.png b/static/img/team/zahash.png new file mode 100644 index 000000000..f8b2d7adb Binary files /dev/null and b/static/img/team/zahash.png differ