Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
6 changes: 4 additions & 2 deletions src/layouts/Base.astro
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -59,7 +59,8 @@ const cta = RELEASED ? { href: DOWNLOAD_URL, label: 'Download' } : { href: to('#
<a href={to('#compare')}>Compare</a>
<a href="/changelog.html">Changelog</a>
<a href={to('#faq')}>FAQ</a>
<a class="nav-kofi" href={KOFI_URL}><Brand name="Ko-fi" />Support</a>
<a class="nav-icon" href={REPO_URL} data-goatcounter-click="star-header"><Brand name="GitHub" />Star{STARS !== undefined && <span class="stars">{STARS}</span>}</a>
<a class="nav-icon nav-kofi" href={KOFI_URL}><Brand name="Ko-fi" />Support</a>
</nav>
<a class="btn btn-sm" href={cta.href} data-goatcounter-click={RELEASED ? 'download-windows' : undefined}>{cta.label}</a>
</div>
Expand Down Expand Up @@ -88,6 +89,7 @@ const cta = RELEASED ? { href: DOWNLOAD_URL, label: 'Download' } : { href: to('#
<nav aria-labelledby="f-follow">
<h2 id="f-follow">Follow</h2>
<ul>
<li><a href={REPO_URL}><Brand name="GitHub" />GitHub</a></li>
{channels.map((c) => <li><a href={c.url} rel="me"><Brand name={c.name} />{c.name}</a></li>)}
<li><a href={KOFI_URL}><Brand name="Ko-fi" />Ko-fi</a></li>
</ul>
Expand Down
9 changes: 6 additions & 3 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import Shot from '../components/Shot.astro';
import Brand from '../components/Brand.astro';
import { getImage } from 'astro:assets';
import type { ImageMetadata } from 'astro';
import { ArrowRight, ArrowUpRight, Download, Plus, Check, X, Minus, FolderLock, Cpu, EyeOff, Play } from '@lucide/astro';
import { RELEASED, SITE_URL, DOWNLOAD_URL, latest } from '../config';
import { ArrowRight, ArrowUpRight, Download, Plus, Check, X, Minus, FolderLock, Cpu, EyeOff, Play, Star } from '@lucide/astro';
import { RELEASED, SITE_URL, DOWNLOAD_URL, REPO_URL, STARS, latest } from '../config';
import { channels, KOFI_URL, SOLIDCRAFT, hero, worksWith, chapters, standards, bento, privacy, models, roadmap as status } from '../data/site';
import { compare } from '../data/compare';

Expand Down Expand Up @@ -261,7 +261,10 @@ const jsonLd = {
<p class="lead reveal">{RELEASED
? 'Download PartBuddy for Windows. Free, open source, no account.'
: 'PartBuddy is in development. Follow the build for new features, real printed parts, and the things that went wrong.'}</p>
{RELEASED && <div class="ctas"><a class="btn btn-primary btn-lg" href={DOWNLOAD_URL} data-goatcounter-click="download-windows"><Download aria-hidden="true" />Download for Windows</a></div>}
{RELEASED && <div class="ctas">
<a class="btn btn-primary btn-lg" href={DOWNLOAD_URL} data-goatcounter-click="download-windows"><Download aria-hidden="true" />Download for Windows</a>
<a class="btn btn-lg" href={REPO_URL} data-goatcounter-click="star-follow"><Star aria-hidden="true" />Star on GitHub{STARS !== undefined && <span class="stars">{STARS}</span>}</a>
</div>}
<ul class="channels">
{channels.map((c) => (
<li><a class="channel" href={c.url} rel="me"><Brand name={c.name} />{c.name}<span class="sr-only"> {c.handle}</span><ArrowUpRight aria-hidden="true" /></a></li>
Expand Down
5 changes: 3 additions & 2 deletions src/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ p { text-wrap: pretty; }
.nav { display: flex; gap: 2px; font-size: 0.875rem; color: var(--muted); }
.nav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 8px; transition: color 0.15s; }
.nav a:hover { color: var(--ink); }
.nav-kofi { gap: 7px; }
.nav-kofi svg { width: 15px; height: 15px; }
.nav-icon { gap: 7px; }
.nav-icon svg { width: 15px; height: 15px; }
.stars { padding: 1px 7px; border-radius: 999px; background: rgb(255 255 255 / 0.08); font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--ink); }
@supports (animation-timeline: scroll()) {
.site-header { animation: header-line linear both; animation-timeline: scroll(root); animation-range: 0 120px; }
@keyframes header-line { to { border-bottom-color: var(--line); } }
Expand Down
Loading