feat: use api to supply social links (#162)

resolves #138
This commit is contained in:
afn
2023-08-09 15:41:57 -04:00
committed by GitHub
parent d808b318bc
commit a27145d554
6 changed files with 65 additions and 43 deletions

View File

@@ -8,14 +8,16 @@ import type {
Asset,
TeamMember,
DonationPlatform,
CryptoWallet
CryptoWallet,
Social
} from '$lib/types';
export type ReposData = Repository[];
export type ReposData = { repositories: Repository[] };
export type PatchesData = { patches: Patch[]; packages: string[] };
export type ReleaseData = { metadata: Metadata; assets: Asset[] };
export type TeamData = { members: TeamMember[] };
export type DonationData = { wallets: CryptoWallet[]; platforms: DonationPlatform[] };
export type SocialsData = { socials: Social[] };
async function get_json(endpoint: string) {
const url = `${settings.api_base_url()}/${endpoint}`;
@@ -23,7 +25,8 @@ async function get_json(endpoint: string) {
}
async function repositories(): Promise<ReposData> {
return await get_json('contributors').then((json) => json.repositories);
const json = await get_json('contributors');
return { repositories: json.repositories };
}
async function manager(): Promise<ReleaseData> {
@@ -59,10 +62,14 @@ async function team(): Promise<TeamData> {
async function donate(): Promise<DonationData> {
const json = await get_json('v2/donations');
return { wallets: json.donations.wallets, platforms: json.donations.links };
}
async function socials(): Promise<SocialsData> {
const json = await get_json('v2/socials');
return { socials: json.socials };
}
export const staleTime = 5 * 60 * 1000;
export const queries = {
manager: {
@@ -89,5 +96,10 @@ export const queries = {
queryKey: ['donate'],
queryFn: donate,
staleTime
},
socials: {
queryKey: ['socials'],
queryFn: socials,
staleTime
}
};