From 17fd9ad4ce7363b9587d8eb262ed517ae372fca8 Mon Sep 17 00:00:00 2001 From: Manuel Staggl Date: Fri, 13 Nov 2026 14:24:12 +0100 Subject: [PATCH] feat: GitHub star links with build-time star count Header, final call to action and footer link the repository; the star count is read from the GitHub API at build time, and a daily scheduled deploy keeps it current. No third-party script for visitors. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/deploy.yml | 3 +++ src/config.ts | 18 ++++++++++++++++++ src/layouts/Base.astro | 6 ++++-- src/pages/index.astro | 9 ++++++--- src/styles/global.css | 5 +++-- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 3333551..7eff398 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,9 @@ on: repository_dispatch: types: [partbuddy-release] workflow_dispatch: + # Daily rebuild so the GitHub star count on the site stays current. + schedule: + - cron: '17 4 * * *' permissions: contents: read diff --git a/src/config.ts b/src/config.ts index 77f346b..1411d3e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -11,3 +11,21 @@ export const SITE_URL = 'https://partbuddy.github.io'; // Own GoatCounter instance (LXC 102 on pve-n100, through the Cloudflare tunnel); empty means no counting. export const GOATCOUNTER_URL = 'https://stats.mstaggl.me'; export const DOWNLOAD_URL = latest?.downloadUrl ?? 'https://github.com/PartBuddy/partbuddy/releases/latest'; + +export const REPO_URL = 'https://github.com/PartBuddy/partbuddy'; +// Star count, read once at build time like the releases (visitors make no requests); without network +// the star links show no number. The daily scheduled deploy keeps it current. +export const STARS: number | undefined = await fetch('https://api.github.com/repos/PartBuddy/partbuddy', { + headers: { Accept: 'application/vnd.github+json', 'User-Agent': 'partbuddy-web-build' }, + signal: AbortSignal.timeout(8000), +}) + .then(async (res) => { + if (!res.ok) throw new Error(`GitHub API ${res.status}`); + const n = ((await res.json()) as { stargazers_count: number }).stargazers_count; + console.info(`[stars] ${n}`); + return n; + }) + .catch((e) => { + console.warn(`[stars] ${(e as Error).message}; no star count`); + return undefined; + }); diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro index f5dc15e..3a5e0bb 100644 --- a/src/layouts/Base.astro +++ b/src/layouts/Base.astro @@ -1,6 +1,6 @@ --- import '../styles/global.css'; -import { RELEASED, SITE_URL, DOWNLOAD_URL, GOATCOUNTER_URL } from '../config'; +import { RELEASED, SITE_URL, DOWNLOAD_URL, GOATCOUNTER_URL, REPO_URL, STARS } from '../config'; import { channels, KOFI_URL } from '../data/site'; import Brand from '../components/Brand.astro'; @@ -59,7 +59,8 @@ const cta = RELEASED ? { href: DOWNLOAD_URL, label: 'Download' } : { href: to('# Compare Changelog FAQ - Support + Star{STARS !== undefined && {STARS}} + Support {cta.label} @@ -88,6 +89,7 @@ const cta = RELEASED ? { href: DOWNLOAD_URL, label: 'Download' } : { href: to('#