a bit of a redesign

This commit is contained in:
satr14 2025-03-27 11:33:29 +07:00
commit 597304e3e3
8 changed files with 186 additions and 262 deletions

View file

@ -1,116 +1,116 @@
export function blog(api: string, base?: string) {
return fetch(`${api}/api/collections/blogs/records?page=1&perPage=1&fields=collectionId,id,title,desc,created,thumbnail&sort=-created`)
.then(res => res.json())
.then((data: {
items: {
collectionId: string,
id: string,
title: string,
desc: string,
created: number,
thumbnail: string,
}[]
}) => {
const blog = data.items[0];
// export function blog(api: string, base?: string) {
// return fetch(`${api}/api/collections/blogs/records?page=1&perPage=1&fields=collectionId,id,title,desc,created,thumbnail&sort=-created`)
// .then(res => res.json())
// .then((data: {
// items: {
// collectionId: string,
// id: string,
// title: string,
// desc: string,
// created: number,
// thumbnail: string,
// }[]
// }) => {
// const blog = data.items[0];
return {
title: blog.title,
desc: blog.desc,
created: blog.created,
// thumbnail: `${api}/api/files/${blog.collectionId}/${blog.id}/${blog.thumbnail}?thumb=320x160`,
url: !base ? '' : `${base}/${blog.id}`,
};
});
}
// return {
// title: blog.title,
// desc: blog.desc,
// created: blog.created,
// // thumbnail: `${api}/api/files/${blog.collectionId}/${blog.id}/${blog.thumbnail}?thumb=320x160`,
// url: !base ? '' : `${base}/${blog.id}`,
// };
// });
// }
export function github(max: number, user: string) {
return fetch(`https://api.github.com/users/${user}/repos?per_page=${max}?type=owner&sort=created`)
.then(res => res.json())
.then((data:
{
fork: boolean,
name: string,
description: string,
html_url: string,
stargazers_count: number,
language: string,
}[]
) => data.filter(repo => !repo.fork).slice(0, max).map(repo => ({
name: repo.name,
desc: repo.description,
url: repo.html_url,
stars: repo.stargazers_count,
lang: repo.language,
}))).catch((e) => [
{ name: 'Error', desc: e.message, url: '', stars: 0, lang: '' },
]);
}
// export function github(max: number, user: string) {
// return fetch(`https://api.github.com/users/${user}/repos?per_page=${max}?type=owner&sort=created`)
// .then(res => res.json())
// .then((data:
// {
// fork: boolean,
// name: string,
// description: string,
// html_url: string,
// stargazers_count: number,
// language: string,
// }[]
// ) => data.filter(repo => !repo.fork).slice(0, max).map(repo => ({
// name: repo.name,
// desc: repo.description,
// url: repo.html_url,
// stars: repo.stargazers_count,
// lang: repo.language,
// }))).catch((e) => [
// { name: 'Error', desc: e.message, url: '', stars: 0, lang: '' },
// ]);
// }
export function discord(id: string) {
return fetch(`https://api.lanyard.rest/v1/users/${id}`)
.then(res => res.json())
.then(({data}: {
data: {
discord_user: {
id: string,
username: string,
avatar: string,
},
discord_status: string,
spotify: {
album_art_url: string,
track_id: string,
song: string,
artist: string,
},
activities: {
type: number,
name: string,
created_at: number,
state: string,
details: string,
assets: {
large_image: string,
small_image: string,
},
application_id: string,
}[],
}
success: boolean,
}) => ({
// avatar: `https://cdn.discordapp.com/avatars/${data.discord_user.id}/${data.discord_user.avatar}.png?size=128`,
username: data.discord_user.username,
status: data.discord_status,
spotify: {
art: data?.spotify?.album_art_url,
link: `https://open.spotify.com/intl-id/track/${data?.spotify?.track_id}`,
song: data?.spotify?.song,
artist: data?.spotify?.artist,
},
activity: data?.activities.filter((a: {type:number}) =>a.type===0).map((activity:
{name: string, created_at: number, state: string, details: string, assets: {large_image: string, small_image: string}, application_id: string}
) => ({
name: activity.name,
started: activity.created_at,
state: activity.state,
details: activity.details,
images: {
large: !activity?.assets?.large_image ? '' : `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity?.assets?.large_image}.png?size=256`,
small: !activity?.assets?.small_image ? '' : `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity?.assets?.small_image}.png?size=256`,
},
})).sort((a: {started:number}, b: {started:number}) => b.started - a.started) || [],
})).catch(() => ({
username: 'Error',
status: 'Error',
spotify: {
art: '',
link: '',
song: '',
artist: '',
},
activity: [],
}));
}
// export function discord(id: string) {
// return fetch(`https://api.lanyard.rest/v1/users/${id}`)
// .then(res => res.json())
// .then(({data}: {
// data: {
// discord_user: {
// id: string,
// username: string,
// avatar: string,
// },
// discord_status: string,
// spotify: {
// album_art_url: string,
// track_id: string,
// song: string,
// artist: string,
// },
// activities: {
// type: number,
// name: string,
// created_at: number,
// state: string,
// details: string,
// assets: {
// large_image: string,
// small_image: string,
// },
// application_id: string,
// }[],
// }
// success: boolean,
// }) => ({
// // avatar: `https://cdn.discordapp.com/avatars/${data.discord_user.id}/${data.discord_user.avatar}.png?size=128`,
// username: data.discord_user.username,
// status: data.discord_status,
// spotify: {
// art: data?.spotify?.album_art_url,
// link: `https://open.spotify.com/intl-id/track/${data?.spotify?.track_id}`,
// song: data?.spotify?.song,
// artist: data?.spotify?.artist,
// },
// activity: data?.activities.filter((a: {type:number}) =>a.type===0).map((activity:
// {name: string, created_at: number, state: string, details: string, assets: {large_image: string, small_image: string}, application_id: string}
// ) => ({
// name: activity.name,
// started: activity.created_at,
// state: activity.state,
// details: activity.details,
// images: {
// large: !activity?.assets?.large_image ? '' : `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity?.assets?.large_image}.png?size=256`,
// small: !activity?.assets?.small_image ? '' : `https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity?.assets?.small_image}.png?size=256`,
// },
// })).sort((a: {started:number}, b: {started:number}) => b.started - a.started) || [],
// })).catch(() => ({
// username: 'Error',
// status: 'Error',
// spotify: {
// art: '',
// link: '',
// song: '',
// artist: '',
// },
// activity: [],
// }));
// }
export function daysUntilBirthday(date: number[]): number {
const today = new Date();
@ -180,18 +180,30 @@ export default {
birthday: [12,6],
timezone: "Asia/Jakarta",
links: {
"NixOS Flake": "https://github.com/SX-9/nix-conf",
"Project part-of.my.id": "https://part-of.my.id/",
"part-of.my.id": "https://part-of.my.id/",
"fetch.sh": "https://fetch.satr14.my.id/",
"NixOS Flakes": "https://github.com/SX-9/nix-conf",
"Forever Maze": "https://forever-maze.satr14.my.id/",
"Chess from scratch": "https://sx-9.github.io/chess-from-scratch/",
"CDN": "https://cdn.satr14.my.id/",
},
communities: {
"part-of.my.id": {
icon: "https://avatars.githubusercontent.com/u/184933425?s=200&v=4",
role: "Founder",
url: "https://part-of.my.id/",
},
"is-a.dev": {
icon: "https://avatars.githubusercontent.com/u/72358814?s=200&v=4",
role: "Maintainer",
url: "https://is-a.dev/",
},
"Hack Club": {
icon: "https://assets.hackclub.com/icon-square.png",
role: "Member",
url: "https://hackclub.com/",
},
},
discord: "882595027132493864",
github: "SX-9",
blog: {
api: "https://blog.satr14.my.id/pb",
base: "https://blog.satr14.my.id/post",
main: "https://blog.satr14.my.id/",
},
nixwebring: 'satr14',
blog: "https://blog.satr14.my.id/",
}