From 3e70e8c22c710bc11f2afc32394cab967949a6c2 Mon Sep 17 00:00:00 2001 From: neil molina Date: Mon, 26 Jun 2023 14:24:41 +0800 Subject: [PATCH] use webp images that are auto-generated --- .github/get-packages-data.js | 24 +++++++++++++++++++++ .github/workflows/cd.yml | 2 +- .github/workflows/staging.yml | 2 +- src/layouts/partials/package-thumbnail.html | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 .github/get-packages-data.js diff --git a/.github/get-packages-data.js b/.github/get-packages-data.js new file mode 100644 index 0000000..5cde315 --- /dev/null +++ b/.github/get-packages-data.js @@ -0,0 +1,24 @@ +const fs = require("fs"); +const packagesURL = "https://app.tea.xyz/v1/packages"; + +async function main() { + const response = await fetch(packagesURL); + const packagesRaw = await response.json(); + const packages = packagesRaw.map((pkg) => ({ + slug: pkg.slug, + homepage: pkg.homepage || pkg.github_url, + name: pkg.name, + full_name: pkg.full_name, + maintainer: pkg.maintainer, + created: pkg.created_at, + desc: pkg.description.replace(/\\/g, "\\\\"), + short_description: (pkg.short_description || pkg.description).replace(/\\/g, "\\\\"), + thumb_image_url: pkg.image_added_at ? `https://gui.tea.xyz/prod/${pkg.full_name}/512x512.webp` : "", + keywords: pkg.keywords, + dl_count: pkg.installs || 0, + installs: pkg.installs || 0, + })); + await fs.writeFileSync("./src/data/packages.json", JSON.stringify(packages, null, 2)); +} + +main(); \ No newline at end of file diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 40d2137..5a64b59 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -27,7 +27,7 @@ jobs: - name: add packages data run: | rm ./src/data/packages.json - curl https://gui.tea.xyz/packages.json -H "Accept: application/json" >> ./src/data/packages.json + node .github/get-packages-data.js - name: Create Package Detail Pages from packages.json uses: getneil/jq-action@v1 diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index dad7485..324cd6b 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -38,7 +38,7 @@ jobs: - name: add packages data run: | rm ./src/data/packages.json - curl https://gui.tea.xyz/packages.json -H "Accept: application/json" >> ./src/data/packages.json + node .github/get-packages-data.js - name: Create Package Detail Pages from packages.json uses: getneil/jq-action@v1 diff --git a/src/layouts/partials/package-thumbnail.html b/src/layouts/partials/package-thumbnail.html index 076bc00..4ba3fce 100644 --- a/src/layouts/partials/package-thumbnail.html +++ b/src/layouts/partials/package-thumbnail.html @@ -1,4 +1,4 @@ -
+