added commit display

This commit is contained in:
2026-11-10 13:52:23 +00:00
parent 5e3b5200e3
commit 38ce5f3554
3 changed files with 121 additions and 1 deletions

View File

@@ -2,7 +2,9 @@ import type { PageServerLoad } from './$types';
import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin'; import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin';
import { getLatestBook } from '#lib/server/komga'; import { getLatestBook } from '#lib/server/komga';
import { getContentItems } from '#lib/server/content'; import { getContentItems } from '#lib/server/content';
import { getLatestCommits } from '#lib/server/gitea';
import type { ContentItem } from '#lib/server/content'; import type { ContentItem } from '#lib/server/content';
import type { GitCommit } from '#lib/server/gitea';
import { import {
JELLYFIN_PLAYLIST_ID, JELLYFIN_PLAYLIST_ID,
JELLYFIN_LIBRARY_ID, JELLYFIN_LIBRARY_ID,
@@ -17,19 +19,22 @@ export const load: PageServerLoad = () => {
const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID); const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID);
const contentItems: ContentItem = getContentItems(globalThis.fetch, CHANNEL_ID, BLOG_URL); const contentItems: ContentItem = getContentItems(globalThis.fetch, CHANNEL_ID, BLOG_URL);
const latestCommits: GitCommit = getLatestCommits(globalThis.fetch, 10);
latestSong.catch(() => {}); latestSong.catch(() => {});
latestSeries.catch(() => {}); latestSeries.catch(() => {});
latestBook.catch(() => {}); latestBook.catch(() => {});
contentItems.catch(() => {}); contentItems.catch(() => {});
latestCommits.catch(() => {});
return { return {
streamed: { streamed: {
latestSong, latestSong,
latestSeries, latestSeries,
latestBook, latestBook,
contentItems contentItems,
latestCommits
} }
}; };
}; };

View File

@@ -3,6 +3,7 @@
import { SiGit, SiHugo, SiYoutube } from '@icons-pack/svelte-simple-icons'; import { SiGit, SiHugo, SiYoutube } from '@icons-pack/svelte-simple-icons';
import Content from './Content.svelte'; import Content from './Content.svelte';
import Commits from './Commits.svelte';
let { data }: { data: PageData } = $props(); let { data }: { data: PageData } = $props();
import voidarcIcon from '../voidarc-hollow.svg?raw'; import voidarcIcon from '../voidarc-hollow.svg?raw';
@@ -187,6 +188,12 @@
</a> </a>
</div> </div>
</div> </div>
{#await data.streamed.latestCommits}
<p>loading commits...</p>
{:then commits}
{console.log(commits)}
<Commits items={commits} />
{/await}
</div> </div>
</div> </div>
</div> </div>

108
src/routes/Commits.svelte Normal file
View File

@@ -0,0 +1,108 @@
<script lang="ts">
import type { GitCommit } from './types';
let { items }: { items: GitCommit[] } = $props();
let containerElement: HTMLDivElement;
let cardElements = $state<HTMLElement[]>([]);
let graphHeight = $state(0);
let nodePositions = $state<{ x: number; y: number }[]>([]);
// Measure the actual centre of every article card.
$effect(() => {
const currentItems = items;
const cards = cardElements.filter(Boolean);
const container = containerElement;
if (!container || cards.length !== currentItems.length) return;
function updatePositions() {
const containerRect = container.getBoundingClientRect();
nodePositions = cards.map((card) => {
const rect = card.getBoundingClientRect();
return {
x: 10,
y: rect.top - containerRect.top + rect.height / 2
};
});
graphHeight = container.scrollHeight;
}
// Initial measurement.
updatePositions();
// Watch for changes in card or container dimensions.
const observer = new ResizeObserver(updatePositions);
observer.observe(container);
cards.forEach((card) => observer.observe(card));
// Also handle viewport changes.
window.addEventListener('resize', updatePositions);
return () => {
observer.disconnect();
window.removeEventListener('resize', updatePositions);
};
});
</script>
<div bind:this={containerElement} class="relative mt-1">
<!-- SVG timeline overlay -->
<svg
class="pointer-events-none absolute top-0 left-0 z-0 overflow-visible"
width="10"
height={graphHeight}
viewBox={`0 0 10 ${graphHeight}`}
>
<!-- Connecting lines -->
{#each nodePositions as node, index}
{#if nodePositions[index + 1]}
<line
x1={node.x}
y1={node.y}
x2={nodePositions[index + 1].x}
y2={nodePositions[index + 1].y}
stroke="currentColor"
stroke-width="2"
class="text-ctp-green"
stroke-linecap="round"
/>
{/if}
{/each}
<!-- Commit nodes -->
{#each nodePositions as node}
<circle
cx={node.x}
cy={node.y}
r="7"
fill="#313244"
stroke="currentColor"
stroke-width="2"
class="text-ctp-green"
/>
{/each}
</svg>
<!-- Article list -->
<div class="mt-3 mr-3 grid grid-flow-row auto-rows-min">
{#each items as item, index (item.hash)}
<div class="relative z-10 grid grid-cols-[1.25rem_minmax(0,1fr)] gap-x-3.5 gap-y-4 pb-3">
<!-- Timeline space -->
<div></div>
<!-- Article card -->
<div bind:this={cardElements[index]} class="min-w-0">
<a href={item.link} class="group flex">
<p class="rounded-md bg-ctp-surface2 px-1">{item.shortHash}</p>
</a>
</div>
</div>
{/each}
</div>
</div>