Show the latest website change in the website Info
This commit is contained in:
parent
625124818f
commit
f56690c8f1
7 changed files with 96 additions and 27 deletions
15
.github/workflows/lint.yml
vendored
15
.github/workflows/lint.yml
vendored
|
@ -1,15 +0,0 @@
|
||||||
name: Lint the code
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- "**"
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
|
||||||
- name: Install modules
|
|
||||||
run: bun install
|
|
||||||
- name: Run ESLint
|
|
||||||
run: bun lint
|
|
|
@ -10,6 +10,7 @@ import { speedruncom } from "./infos/gaming/speedruncom";
|
||||||
import { anilist } from "./infos/media/anilist";
|
import { anilist } from "./infos/media/anilist";
|
||||||
import { lastfm } from "./infos/media/lastfm";
|
import { lastfm } from "./infos/media/lastfm";
|
||||||
import { umami } from "./infos/website/umami";
|
import { umami } from "./infos/website/umami";
|
||||||
|
import { kitsudev as kitsudev2 } from "./infos/website/kitsudev";
|
||||||
|
|
||||||
const info_routes: Record<string, Handler[]> = {
|
const info_routes: Record<string, Handler[]> = {
|
||||||
coding: [github, gitlab, kitsudev],
|
coding: [github, gitlab, kitsudev],
|
||||||
|
@ -18,7 +19,7 @@ const info_routes: Record<string, Handler[]> = {
|
||||||
// hacking: [hackthebox],
|
// hacking: [hackthebox],
|
||||||
// japanese: [wanikani],
|
// japanese: [wanikani],
|
||||||
media: [anilist, lastfm],
|
media: [anilist, lastfm],
|
||||||
website: [umami],
|
website: [umami, kitsudev2],
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Handler = (req: URLSearchParams) => Promise<Response>;
|
export type Handler = (req: URLSearchParams) => Promise<Response>;
|
||||||
|
|
40
api/infos/website/kitsudev.ts
Normal file
40
api/infos/website/kitsudev.ts
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import { type KitsudevInfo } from "#Infos/Website/KitsuDev.tsx";
|
||||||
|
import type { Handler } from "../..";
|
||||||
|
|
||||||
|
const username = "Taevas";
|
||||||
|
const repository = "taevas.xyz";
|
||||||
|
|
||||||
|
export const kitsudev: Handler = async () => {
|
||||||
|
/** https://kitsunes.dev/api/swagger#/repository/repoGetAllCommits */
|
||||||
|
const kitsudev = await (await fetch(`https://kitsunes.dev/api/v1/repos/${username}/${repository}/commits?limit=1`)).json() as [{
|
||||||
|
html_url: string
|
||||||
|
commit: {
|
||||||
|
author: {
|
||||||
|
name: string
|
||||||
|
date: string
|
||||||
|
}
|
||||||
|
message: string
|
||||||
|
}
|
||||||
|
files: {
|
||||||
|
filename: string
|
||||||
|
status: string
|
||||||
|
}[]
|
||||||
|
stats: {
|
||||||
|
total: number
|
||||||
|
additions: number
|
||||||
|
deletions: number
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
|
const info: KitsudevInfo = {
|
||||||
|
url: kitsudev[0].html_url,
|
||||||
|
message: kitsudev[0].commit.message,
|
||||||
|
author: kitsudev[0].commit.author.name,
|
||||||
|
date: kitsudev[0].commit.author.date,
|
||||||
|
files_modified: kitsudev[0].files.length,
|
||||||
|
lines_added: kitsudev[0].stats.additions,
|
||||||
|
lines_removed: kitsudev[0].stats.deletions,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Response.json(info, {status: 200});
|
||||||
|
};
|
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
14
package.json
14
package.json
|
@ -18,22 +18,22 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "^3.3.1",
|
"@eslint/eslintrc": "^3.3.1",
|
||||||
"@eslint/js": "^9.23.0",
|
"@eslint/js": "^9.24.0",
|
||||||
"@stylistic/eslint-plugin": "^3.1.0",
|
"@stylistic/eslint-plugin": "^3.1.0",
|
||||||
"@tailwindcss/forms": "^0.5.10",
|
"@tailwindcss/forms": "^0.5.10",
|
||||||
"@tailwindcss/postcss": "^4.1.1",
|
"@tailwindcss/postcss": "^4.1.3",
|
||||||
"@types/bun": "^1.2.8",
|
"@types/bun": "^1.2.8",
|
||||||
"@types/react": "^19.1.0",
|
"@types/react": "^19.1.0",
|
||||||
"@types/react-dom": "^19.1.1",
|
"@types/react-dom": "^19.1.1",
|
||||||
"dotenv": "^16.4.7",
|
"dotenv": "^16.4.7",
|
||||||
"eslint": "^9.23.0",
|
"eslint": "^9.24.0",
|
||||||
"eslint-config-xo-typescript": "^7.0.0",
|
"eslint-config-xo-typescript": "^7.0.0",
|
||||||
"eslint-plugin-react": "^7.37.4",
|
"eslint-plugin-react": "^7.37.5",
|
||||||
"postcss": "^8.5.3",
|
"postcss": "^8.5.3",
|
||||||
"react-animate-height": "^3.2.3",
|
"react-animate-height": "^3.2.3",
|
||||||
"tailwindcss": "^4.1.1",
|
"tailwindcss": "^4.1.3",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.3",
|
||||||
"typescript-eslint": "^8.29.0",
|
"typescript-eslint": "^8.29.1",
|
||||||
"vite": "^6.2.5"
|
"vite": "^6.2.5"
|
||||||
},
|
},
|
||||||
"imports": {
|
"imports": {
|
||||||
|
|
42
src/Infos/Website/KitsuDev.tsx
Normal file
42
src/Infos/Website/KitsuDev.tsx
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import React, {useState, useEffect} from "react";
|
||||||
|
import Website from "../Website.tsx";
|
||||||
|
import DataHandler from "#parts/DataHandler.tsx";
|
||||||
|
import Link from "#parts/Link.tsx";
|
||||||
|
|
||||||
|
export type KitsudevInfo = {
|
||||||
|
url: string,
|
||||||
|
message: string,
|
||||||
|
author: string,
|
||||||
|
date: string,
|
||||||
|
files_modified: number,
|
||||||
|
lines_added: number,
|
||||||
|
lines_removed: number,
|
||||||
|
} | undefined;
|
||||||
|
|
||||||
|
export default function KitsuDev() {
|
||||||
|
const {data, error, setError} = DataHandler<KitsudevInfo>("infos/website/kitsudev", 60 * 20);
|
||||||
|
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
try {
|
||||||
|
setElements([
|
||||||
|
<Link key={"kitsudev-link"} classes="mb-1 px-1 py-2 inline-block w-full font-bold leading-[18px] bg-white text-blue-800" link={data.url} text={data.message}/>,
|
||||||
|
<p key={"kitsudev-date"}><strong>{data.date.substring(0, data.date.indexOf("T"))}</strong></p>,
|
||||||
|
<p key={"kitsudev-changes"}>{data.files_modified} files changed <span className="whitespace-nowrap">(<span className="text-green-400">+{data.lines_added}</span> <span className="text-red-400">-{data.lines_removed}</span>)</span></p>
|
||||||
|
]);
|
||||||
|
} catch {
|
||||||
|
setError(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Website
|
||||||
|
name="KitsuDev"
|
||||||
|
link={data?.url ? data.url.substring(0, data.url.indexOf("/commit")) : ""}
|
||||||
|
elements={elements}
|
||||||
|
error={error}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,15 +1,16 @@
|
||||||
import React, {useEffect, useState} from "react";
|
import React, {useEffect, useState} from "react";
|
||||||
import Info from "../Info.tsx";
|
import Info from "../Info.tsx";
|
||||||
import Umami from "./Umami.tsx";
|
|
||||||
import DataHandler from "#parts/DataHandler.tsx";
|
import DataHandler from "#parts/DataHandler.tsx";
|
||||||
|
import Umami from "./Umami.tsx";
|
||||||
|
import KitsuDev from "./KitsuDev.tsx";
|
||||||
|
|
||||||
export default function Website() {
|
export default function Website() {
|
||||||
const {data} = DataHandler<boolean>("infos/token?service=umami", 60 * 60 * 8, false);
|
const {data} = DataHandler<boolean>("infos/token?service=umami", 60 * 60 * 8, false);
|
||||||
const [websites, setWebsites] = useState([] as React.JSX.Element[]);
|
const [websites, setWebsites] = useState([] as React.JSX.Element[]);
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// setWebsites([<aWebsite key={"awebsite"}/>]);
|
setWebsites([<KitsuDev key={"kitsudev"}/>]);
|
||||||
// }, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue