- Linktree-style homepage with photo, social links, and self-hosted services (container registry, Git server) - Registry pages rendered on demand from Harbor via a live content collection, cached in memory (60s fresh, 10min stale-while-revalidate) - Pinned registry images (PINNED_IMAGES) shown first with a star - Node standalone server with security headers; self-contained server build so the Docker image ships no node_modules - Gitea workflow building multi-arch images for Flux Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
---
|
||||
export const prerender = false; // lets on-demand pages rewrite to it
|
||||
|
||||
import Base from '../layouts/Base.astro';
|
||||
---
|
||||
|
||||
<Base title="Not found">
|
||||
<h1>Not found</h1>
|
||||
<p>That page doesn't exist. <a href="/">Go home</a> or <a href="/registry/">browse the registry</a>.</p>
|
||||
</Base>
|
||||
@@ -0,0 +1,159 @@
|
||||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import Base from '../layouts/Base.astro';
|
||||
import { SITE_TITLE } from '../consts';
|
||||
import { GITEA_ICON, SOCIAL_LINKS } from '../social';
|
||||
|
||||
const NAME = 'Philipp Traber';
|
||||
|
||||
// Drop a photo at src/assets/profile.{jpg,jpeg,png,webp,avif} and it is picked up
|
||||
// automatically; until then an initials placeholder is shown.
|
||||
const photos = import.meta.glob<{ default: ImageMetadata }>(
|
||||
'../assets/profile.{jpg,jpeg,png,webp,avif}',
|
||||
{ eager: true },
|
||||
);
|
||||
const photo = Object.values(photos)[0]?.default;
|
||||
---
|
||||
|
||||
<Base title={SITE_TITLE}>
|
||||
<section class="profile">
|
||||
{
|
||||
photo ? (
|
||||
<Image src={photo} alt={NAME} width={128} height={128} class="avatar" loading="eager" />
|
||||
) : (
|
||||
<div class="avatar placeholder" aria-hidden="true">PT</div>
|
||||
)
|
||||
}
|
||||
<h1>{NAME}</h1>
|
||||
<p class="tagline">
|
||||
Welcome to my homepage.<br />
|
||||
Feel free to explore the stuff I do or contact me via LinkedIn.
|
||||
</p>
|
||||
<ul class="links">
|
||||
{
|
||||
SOCIAL_LINKS.map(({ label, href, icon }) => (
|
||||
<li>
|
||||
<a href={href} rel="me noopener" target="_blank">
|
||||
<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true">
|
||||
<path d={icon} fill="currentColor" />
|
||||
</svg>
|
||||
<span>{label}</span>
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
<li class="own">
|
||||
<a href="/registry/">
|
||||
<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true">
|
||||
<path
|
||||
d="M21 7.5 12 3 3 7.5v9L12 21l9-4.5v-9ZM12 12 3.5 7.75M12 12l8.5-4.25M12 12v8.75"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.75"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
<span>Container registry</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="own">
|
||||
<a href="https://git.traberph.de/" rel="me noopener" target="_blank">
|
||||
<svg viewBox="0 0 24 24" width="24" height="24" aria-hidden="true">
|
||||
<path d={GITEA_ICON} fill="currentColor" />
|
||||
</svg>
|
||||
<span>Git server</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.profile {
|
||||
max-width: 36rem;
|
||||
margin-inline: auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--surface);
|
||||
color: var(--muted);
|
||||
font-size: 2.5rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
font-size: 1.75rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.tagline {
|
||||
margin: 0 0 1rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.links {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Logo pinned left; an equal-width empty column on the right keeps the label centered. */
|
||||
.links a {
|
||||
display: grid;
|
||||
grid-template-columns: 24px 1fr 24px;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 0.875rem 1.25rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
transition: border-color 0.15s, transform 0.15s;
|
||||
}
|
||||
|
||||
.links a:hover {
|
||||
border-color: var(--accent);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.links span {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Space only above the first self-hosted link, separating it from the social links. */
|
||||
.links li:not(.own) + .own {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.links a {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.links a:hover {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,135 @@
|
||||
---
|
||||
import { getLiveEntry, render } from 'astro:content';
|
||||
import { LiveEntryNotFoundError } from 'astro/content/runtime';
|
||||
import Base from '../../layouts/Base.astro';
|
||||
import PullCommand from '../../components/PullCommand.astro';
|
||||
import VulnBadge from '../../components/VulnBadge.astro';
|
||||
import { formatBytes, formatDate, formatPlatform, shortDigest } from '../../lib/format';
|
||||
import { REGISTRY_CACHE } from '../../consts';
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
const { entry: repo, error } = await getLiveEntry('registry', Astro.params.id ?? '');
|
||||
if (!repo) {
|
||||
if (error && !(error instanceof LiveEntryNotFoundError)) {
|
||||
console.error(error);
|
||||
return new Response('The registry is unreachable right now. Please try again in a moment.', {
|
||||
status: 503,
|
||||
headers: { 'Content-Type': 'text/plain; charset=utf-8', 'Retry-After': '30' },
|
||||
});
|
||||
}
|
||||
return Astro.rewrite('/404/');
|
||||
}
|
||||
if (Astro.cache.enabled) Astro.cache.set(REGISTRY_CACHE);
|
||||
|
||||
const { data } = repo;
|
||||
const { Content } = await render(repo);
|
||||
// Prefer the `latest` tag; Harbor doesn't return tags in a stable order.
|
||||
const latest = data.artifacts.find((a) => a.tags.includes('latest')) ?? data.artifacts[0];
|
||||
const pullTag = latest?.tags.includes('latest') ? 'latest' : latest?.tags[0];
|
||||
---
|
||||
|
||||
<Base title={data.fullName} description={`Container image ${data.fullName}`}>
|
||||
<p class="crumbs"><a href="/registry/">Registry</a> / {data.project}</p>
|
||||
<h1>{data.name}</h1>
|
||||
|
||||
{latest && <PullCommand image={pullTag ? `${data.pullRef}:${pullTag}` : `${data.pullRef}@${latest.digest}`} />}
|
||||
|
||||
{
|
||||
data.description && (
|
||||
<section class="description">
|
||||
<Content />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
<h2>Tags</h2>
|
||||
{
|
||||
data.artifacts.length === 0 ? (
|
||||
<p>No tagged artifacts.</p>
|
||||
) : (
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Tags</th>
|
||||
<th scope="col">Digest</th>
|
||||
<th scope="col">Platforms</th>
|
||||
<th scope="col">Size</th>
|
||||
<th scope="col">Pushed</th>
|
||||
<th scope="col">Scan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.artifacts.map((a) => (
|
||||
<tr>
|
||||
<td>
|
||||
{a.tags.map((t) => (
|
||||
<code class="tag">{t}</code>
|
||||
))}
|
||||
</td>
|
||||
<td>
|
||||
<code title={a.digest}>{shortDigest(a.digest)}</code>
|
||||
</td>
|
||||
<td>{a.platforms.map(formatPlatform).join(', ') || '—'}</td>
|
||||
<td>{formatBytes(a.size)}</td>
|
||||
<td>
|
||||
<time datetime={a.pushedAt.toISOString()}>{formatDate(a.pushedAt)}</time>
|
||||
</td>
|
||||
<td>
|
||||
<VulnBadge scan={a.vulnerabilities} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</Base>
|
||||
|
||||
<style>
|
||||
.crumbs {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.description {
|
||||
margin-block: 2rem;
|
||||
}
|
||||
|
||||
.table-wrap {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: left;
|
||||
padding: 0.5rem 0.75rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
th {
|
||||
color: var(--muted);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.tag {
|
||||
display: inline-block;
|
||||
margin: 0 0.25rem 0.25rem 0;
|
||||
padding: 0 0.4rem;
|
||||
background: var(--code-bg);
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,154 @@
|
||||
---
|
||||
import { getLiveCollection } from 'astro:content';
|
||||
import Base from '../../layouts/Base.astro';
|
||||
import { formatDate } from '../../lib/format';
|
||||
import { PINNED_IMAGES, REGISTRY_CACHE } from '../../consts';
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
const { entries = [], error } = await getLiveCollection('registry');
|
||||
if (error) {
|
||||
console.error(error);
|
||||
Astro.response.status = 503;
|
||||
} else if (Astro.cache.enabled) {
|
||||
Astro.cache.set(REGISTRY_CACHE);
|
||||
}
|
||||
|
||||
// Pinned images first (in configured order), then the rest by most recently updated.
|
||||
const pinRank = (id: string) => {
|
||||
const i = PINNED_IMAGES.indexOf(id);
|
||||
return i === -1 ? Infinity : i;
|
||||
};
|
||||
const repos = entries.toSorted(
|
||||
(a, b) => pinRank(a.id) - pinRank(b.id) || b.data.updatedAt.getTime() - a.data.updatedAt.getTime(),
|
||||
);
|
||||
---
|
||||
|
||||
<Base title="Registry" description="Public container images hosted on my Harbor registry.">
|
||||
<h1>Registry</h1>
|
||||
|
||||
{
|
||||
error ? (
|
||||
<p>The registry is unreachable right now. Please try again in a moment.</p>
|
||||
) : repos.length === 0 ? (
|
||||
<p>No public images yet.</p>
|
||||
) : (
|
||||
<>
|
||||
<label for="filter" class="visually-hidden">
|
||||
Filter images
|
||||
</label>
|
||||
<input id="filter" type="search" placeholder="Filter images…" autocomplete="off" hidden />
|
||||
|
||||
<ul class="repos">
|
||||
{repos.map(({ id, data }) => (
|
||||
<li
|
||||
class:list={{ pinned: PINNED_IMAGES.includes(id) }}
|
||||
data-search={`${data.fullName} ${data.artifacts.flatMap((a) => a.tags).join(' ')}`.toLowerCase()}
|
||||
>
|
||||
<a href={`/registry/${id}/`}>
|
||||
<span class="project">{data.project}/</span>
|
||||
<strong>{data.name}</strong>
|
||||
{PINNED_IMAGES.includes(id) && (
|
||||
<svg class="star" viewBox="0 0 16 16" width="16" height="16" role="img" aria-label="Pinned">
|
||||
<title>Pinned</title>
|
||||
<path
|
||||
fill="currentColor"
|
||||
d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Z"
|
||||
/>
|
||||
</svg>
|
||||
)}
|
||||
</a>
|
||||
<span class="meta">
|
||||
{data.artifacts.length} tagged · {data.pullCount} pulls · updated{' '}
|
||||
<time datetime={data.updatedAt.toISOString()}>{formatDate(data.updatedAt)}</time>
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p id="no-match" hidden>
|
||||
No images match.
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
}
|
||||
</Base>
|
||||
|
||||
<script>
|
||||
// Client-side filter; the list is fully usable without JS.
|
||||
const input = document.querySelector<HTMLInputElement>('#filter');
|
||||
const items = document.querySelectorAll<HTMLLIElement>('.repos li');
|
||||
const noMatch = document.querySelector<HTMLElement>('#no-match');
|
||||
|
||||
if (input && noMatch) {
|
||||
input.hidden = false;
|
||||
input.addEventListener('input', () => {
|
||||
const q = input.value.trim().toLowerCase();
|
||||
let visible = 0;
|
||||
for (const li of items) {
|
||||
li.hidden = !li.dataset.search?.includes(q);
|
||||
if (!li.hidden) visible++;
|
||||
}
|
||||
noMatch.hidden = visible > 0;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
input {
|
||||
width: 100%;
|
||||
font: inherit;
|
||||
padding: 0.5rem 0.75rem;
|
||||
margin-bottom: 1.5rem; /* = gap between pinned and other images (0.5rem grid gap + 1rem) */
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.repos {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: grid;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.repos li {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.25rem 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
}
|
||||
|
||||
.repos li[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.repos a {
|
||||
text-decoration: none;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.star {
|
||||
vertical-align: -2px;
|
||||
margin-left: 0.35rem;
|
||||
}
|
||||
|
||||
/* Separate pinned images from the rest, like the self-hosted links on the homepage. */
|
||||
.repos .pinned:not([hidden]) + li:not(.pinned) {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.project,
|
||||
.meta {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.meta {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user