Files
moeka-project/docs/.vitepress/contributors.ts
T
2026-08-26 20:13:10 +08:00

53 lines
1.3 KiB
TypeScript

import type { DefaultTheme } from 'vitepress'
import contributorNames from './contributor-names.json'
export interface Contributor {
name: string
avatar: string
}
export interface CoreTeam extends DefaultTheme.TeamMember {
// required to download avatars from GitHub
github: string
twitter?: string
mastodon?: string
discord?: string
youtube?: string
}
const contributorsAvatars: Record<string, string> = {}
function getAvatarUrl(name: string) {
return `https://github.com/${name}.png`
}
export const contributors = (contributorNames as string[]).reduce((acc, name) => {
contributorsAvatars[name] = getAvatarUrl(name)
acc.push({ name, avatar: contributorsAvatars[name] })
return acc
}, [] as Contributor[])
function createLinks(tm: CoreTeam): CoreTeam {
tm.links = [{ icon: 'github', link: `https://github.com/${tm.github}` }]
if (tm.mastodon)
tm.links.push({ icon: 'mastodon', link: tm.mastodon })
if (tm.discord)
tm.links.push({ icon: 'discord', link: tm.discord })
if (tm.youtube)
tm.links.push({ icon: 'youtube', link: `https://www.youtube.com/@${tm.youtube}` })
if (tm.twitter)
tm.links.push({ icon: 'twitter', link: `https://twitter.com/${tm.twitter}` })
return tm
}
// TODO
const plainTeamMembers: CoreTeam[] = []
const teamMembers = plainTeamMembers.map(tm => createLinks(tm))
export { teamMembers }