added content with cool graph :D

This commit is contained in:
2026-11-04 19:37:01 +00:00
parent 1ce397b734
commit fc24865941
11 changed files with 269 additions and 69 deletions

View File

@@ -3,9 +3,9 @@ export const immutable = [];
export const prerendered = [];
export const assets = [
{"path":"robots.txt"},
{"path":"voidarc-hollow.svg"},
{"path":"adumh00man.png"},
{"path":"robots.txt"}
{"path":"adumh00man.png"}
];
export const routes = [

View File

@@ -3,5 +3,5 @@ globalThis.__sveltekit_dev = {
env: {
// empty
},
version: "1793799746966"
version: "1793818191005"
};

View File

@@ -2,7 +2,8 @@
import type { PageServerLoad } from './$types';
import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin';
import { getLatestBook } from '#lib/server/komga';
import { fetchBlogArticles, getChannelInfo } from '#lib/server/content';
import { getContentItems } from '#lib/server/content';
import type { ContentItem } from '#lib/server/content';
import {
JELLYFIN_PLAYLIST_ID,
JELLYFIN_LIBRARY_ID,
@@ -13,21 +14,23 @@ import {
export const load = () => {
const latestSong = getLatestPlaylistSong(globalThis.fetch, JELLYFIN_PLAYLIST_ID);
console.log(JELLYFIN_LIBRARY_ID);
const latestSeries = getLatestWatchedSeries(globalThis.fetch, JELLYFIN_LIBRARY_ID);
const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID);
const blogArticles = fetchBlogArticles(BLOG_URL);
const info = getChannelInfo(CHANNEL_ID);
const contentItems: ContentItem = getContentItems(globalThis.fetch, CHANNEL_ID, BLOG_URL);
latestSong.catch(() => {});
latestSeries.catch(() => {});
latestBook.catch(() => {});
contentItems.catch(() => {});
return {
streamed: {
latestSong,
latestSeries,
latestBook
latestBook,
contentItems
}
};
};

2
node_modules/$app/types/index.d.ts generated vendored
View File

@@ -18,7 +18,7 @@ declare module "$app/types" {
};
Path(): "" | `artwork/${string}` & {} | `books/${string}` & {} | `posters/${string}` & {};
ResolvedPathname(): `${"/" | `/${string}/`}${ReturnType<AppTypes['Path']>}`;
AssetPath(): "voidarc-hollow.svg" | "adumh00man.png" | "robots.txt";
AssetPath(): "robots.txt" | "voidarc-hollow.svg" | "adumh00man.png";
}
}

View File

@@ -1,127 +1,127 @@
{
"hash": "0ced44a7",
"configHash": "457bb450",
"hash": "4a575b03",
"configHash": "ad009091",
"lockfileHash": "639dee1d",
"browserHash": "2cd5c438",
"browserHash": "05feef3d",
"optimized": {
"@sveltejs/kit > devalue": {
"src": "../../devalue/index.js",
"file": "@sveltejs_kit_n_devalue.js",
"fileHash": "077eba68",
"fileHash": "18e5ce1c",
"needsInterop": false
},
"@sveltejs/kit > esm-env": {
"src": "../../esm-env/index.js",
"file": "@sveltejs_kit_n_esm-env.js",
"fileHash": "a4cf7607",
"fileHash": "213b1794",
"needsInterop": false
},
"svelte": {
"src": "../../svelte/src/index-client.js",
"file": "svelte.js",
"fileHash": "421b260f",
"fileHash": "360a8b4b",
"needsInterop": false
},
"svelte/animate": {
"src": "../../svelte/src/animate/index.js",
"file": "svelte_animate.js",
"fileHash": "d761958c",
"fileHash": "f58f932f",
"needsInterop": false
},
"svelte/attachments": {
"src": "../../svelte/src/attachments/index.js",
"file": "svelte_attachments.js",
"fileHash": "40dec634",
"fileHash": "e974f528",
"needsInterop": false
},
"svelte/easing": {
"src": "../../svelte/src/easing/index.js",
"file": "svelte_easing.js",
"fileHash": "753941bf",
"fileHash": "4e0f2ace",
"needsInterop": false
},
"svelte/events": {
"src": "../../svelte/src/events/index.js",
"file": "svelte_events.js",
"fileHash": "874101d9",
"fileHash": "cf87672c",
"needsInterop": false
},
"svelte/internal": {
"src": "../../svelte/src/internal/index.js",
"file": "svelte_internal.js",
"fileHash": "66d8aa91",
"fileHash": "c7886738",
"needsInterop": true
},
"svelte/internal/client": {
"src": "../../svelte/src/internal/client/index.js",
"file": "svelte_internal_client.js",
"fileHash": "9aa5233d",
"fileHash": "458e73ff",
"needsInterop": false
},
"svelte/internal/disclose-version": {
"src": "../../svelte/src/internal/disclose-version.js",
"file": "svelte_internal_disclose-version.js",
"fileHash": "9d777fc3",
"fileHash": "3524a2e0",
"needsInterop": false
},
"svelte/internal/flags/async": {
"src": "../../svelte/src/internal/flags/async.js",
"file": "svelte_internal_flags_async.js",
"fileHash": "870fd5c6",
"fileHash": "34ea823c",
"needsInterop": false
},
"svelte/internal/flags/legacy": {
"src": "../../svelte/src/internal/flags/legacy.js",
"file": "svelte_internal_flags_legacy.js",
"fileHash": "dad1c00c",
"fileHash": "6b70aded",
"needsInterop": false
},
"svelte/internal/flags/tracing": {
"src": "../../svelte/src/internal/flags/tracing.js",
"file": "svelte_internal_flags_tracing.js",
"fileHash": "fbd2f1f5",
"fileHash": "44339d78",
"needsInterop": false
},
"svelte/legacy": {
"src": "../../svelte/src/legacy/legacy-client.js",
"file": "svelte_legacy.js",
"fileHash": "dd491873",
"fileHash": "f2f289c1",
"needsInterop": false
},
"svelte/motion": {
"src": "../../svelte/src/motion/index.js",
"file": "svelte_motion.js",
"fileHash": "2be2366e",
"fileHash": "c4cb6258",
"needsInterop": false
},
"svelte > clsx": {
"src": "../../clsx/dist/clsx.mjs",
"file": "svelte_n_clsx.js",
"fileHash": "51f7865c",
"fileHash": "852accfb",
"needsInterop": false
},
"svelte/reactivity": {
"src": "../../svelte/src/reactivity/index-client.js",
"file": "svelte_reactivity.js",
"fileHash": "6427ee44",
"fileHash": "a5cb57a3",
"needsInterop": false
},
"svelte/reactivity/window": {
"src": "../../svelte/src/reactivity/window/index.js",
"file": "svelte_reactivity_window.js",
"fileHash": "3006f4a4",
"fileHash": "a233b414",
"needsInterop": false
},
"svelte/store": {
"src": "../../svelte/src/store/index-client.js",
"file": "svelte_store.js",
"fileHash": "92bd9482",
"fileHash": "37656487",
"needsInterop": false
},
"svelte/transition": {
"src": "../../svelte/src/transition/index.js",
"file": "svelte_transition.js",
"fileHash": "8f073a86",
"fileHash": "6b011d62",
"needsInterop": false
}
},

View File

@@ -1,127 +1,127 @@
{
"hash": "3e7a0d0d",
"configHash": "8e25bbcd",
"hash": "d1bc081a",
"configHash": "33341ae9",
"lockfileHash": "639dee1d",
"browserHash": "27857297",
"browserHash": "62468ded",
"optimized": {
"svelte": {
"src": "../../svelte/src/index-server.js",
"file": "svelte.js",
"fileHash": "d22346d3",
"fileHash": "3bcb089c",
"needsInterop": false
},
"svelte/animate": {
"src": "../../svelte/src/animate/index.js",
"file": "svelte_animate.js",
"fileHash": "e765e3ef",
"fileHash": "8cafd7ad",
"needsInterop": false
},
"svelte/attachments": {
"src": "../../svelte/src/attachments/index.js",
"file": "svelte_attachments.js",
"fileHash": "230d11ca",
"fileHash": "12d2e676",
"needsInterop": false
},
"svelte/compiler": {
"src": "../../svelte/src/compiler/index.js",
"file": "svelte_compiler.js",
"fileHash": "16b968d1",
"fileHash": "64ca12fc",
"needsInterop": false
},
"svelte/easing": {
"src": "../../svelte/src/easing/index.js",
"file": "svelte_easing.js",
"fileHash": "318452c3",
"fileHash": "422f6a4d",
"needsInterop": false
},
"svelte/events": {
"src": "../../svelte/src/events/index.js",
"file": "svelte_events.js",
"fileHash": "b44561dd",
"fileHash": "c5b9aff7",
"needsInterop": false
},
"svelte/internal": {
"src": "../../svelte/src/internal/index.js",
"file": "svelte_internal.js",
"fileHash": "1f57385d",
"fileHash": "ef810521",
"needsInterop": true
},
"svelte/internal/client": {
"src": "../../svelte/src/internal/client/index.js",
"file": "svelte_internal_client.js",
"fileHash": "4bd4ef05",
"fileHash": "c553ffd0",
"needsInterop": false
},
"svelte/internal/disclose-version": {
"src": "../../svelte/src/internal/disclose-version.js",
"file": "svelte_internal_disclose-version.js",
"fileHash": "0a695c1d",
"fileHash": "2059fb32",
"needsInterop": false
},
"svelte/internal/flags/async": {
"src": "../../svelte/src/internal/flags/async.js",
"file": "svelte_internal_flags_async.js",
"fileHash": "da9d06e5",
"fileHash": "af29dde1",
"needsInterop": false
},
"svelte/internal/flags/legacy": {
"src": "../../svelte/src/internal/flags/legacy.js",
"file": "svelte_internal_flags_legacy.js",
"fileHash": "17637ba5",
"fileHash": "e37a2b6c",
"needsInterop": false
},
"svelte/internal/flags/tracing": {
"src": "../../svelte/src/internal/flags/tracing.js",
"file": "svelte_internal_flags_tracing.js",
"fileHash": "1e1653ad",
"fileHash": "bbd79bf4",
"needsInterop": false
},
"svelte/internal/server": {
"src": "../../svelte/src/internal/server/index.js",
"file": "svelte_internal_server.js",
"fileHash": "6227ee1c",
"fileHash": "235c7ccc",
"needsInterop": false
},
"svelte/legacy": {
"src": "../../svelte/src/legacy/legacy-server.js",
"file": "svelte_legacy.js",
"fileHash": "07215f21",
"fileHash": "03f9ab95",
"needsInterop": false
},
"svelte/motion": {
"src": "../../svelte/src/motion/index.js",
"file": "svelte_motion.js",
"fileHash": "1b3e4942",
"fileHash": "2eed1898",
"needsInterop": false
},
"svelte/reactivity": {
"src": "../../svelte/src/reactivity/index-server.js",
"file": "svelte_reactivity.js",
"fileHash": "8c82a551",
"fileHash": "81f9cc19",
"needsInterop": false
},
"svelte/reactivity/window": {
"src": "../../svelte/src/reactivity/window/index.js",
"file": "svelte_reactivity_window.js",
"fileHash": "365c4854",
"fileHash": "22c98bed",
"needsInterop": false
},
"svelte/server": {
"src": "../../svelte/src/server/index.js",
"file": "svelte_server.js",
"fileHash": "7bcc9525",
"fileHash": "0700a002",
"needsInterop": false
},
"svelte/store": {
"src": "../../svelte/src/store/index-server.js",
"file": "svelte_store.js",
"fileHash": "1f5a01dd",
"fileHash": "1e270fb5",
"needsInterop": false
},
"svelte/transition": {
"src": "../../svelte/src/transition/index.js",
"file": "svelte_transition.js",
"fileHash": "8f973c44",
"fileHash": "df7a9a2c",
"needsInterop": false
}
},

View File

@@ -1,6 +1,14 @@
import { XMLParser } from 'fast-xml-parser';
import { GOOGLE_API_KEY } from '$app/env/private';
export interface ContentItem {
title: string;
description: string;
published: Date;
image: string | undefined;
link: string;
}
const parser = new XMLParser({
ignoreAttributes: false,
attributeNamePrefix: '@_',
@@ -8,7 +16,7 @@ const parser = new XMLParser({
trimValues: true
});
async function fetchXml(url: string) {
async function fetchXml(fetch: typeof globalThis.fetch, url: string) {
const response = await fetch(url);
if (!response.ok) {
@@ -20,16 +28,80 @@ async function fetchXml(url: string) {
return parser.parse(xmlText);
}
export async function fetchBlogArticles(url: string) {
const blogArticles = await fetchXml(url);
async function fetchBlogArticles(fetch: typeof globalThis.fetch, url: string) {
// Need to make into interface
const blogArticles = await fetchXml(fetch, url);
let items: ContentItem[] = [];
for (let article of blogArticles.rss.channel.item) {
items.push({
title: article.title,
description: article.description,
published: new Date(article.pubDate),
link: article.link,
image: undefined
});
}
return items.slice(0, 5);
}
export async function getChannelInfo(channelId: string) {
async function getContentPlaylistId(fetch: typeof globalThis.fetch, channelId: string) {
const response = await fetch(
`https://www.googleapis.com/youtube/v3/channels?part=contentDetails&id=${channelId}&key=${GOOGLE_API_KEY}`
);
const data = await response.json();
if (!response.ok) {
throw new Error(`Failed to get Channel Information: ${response.status}`);
}
// Channel uploads collection
return data.items[0].contentDetails.relatedPlaylists.uploads;
}
async function getLatestContent(
fetch: typeof globalThis.fetch,
channelId: string
): Promise<ContentItem[]> {
const playlistId = await getContentPlaylistId(fetch, channelId);
const response = await fetch(
`https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,contentDetails&playlistId=${playlistId}&maxResults=5&key=${GOOGLE_API_KEY}`
);
if (!response.ok) {
throw new Error(`Failed to get Channel Content: ${response.status}`);
}
const data = await response.json();
let items: ContentItem[] = [];
for (let video of data.items) {
const info = video.snippet;
items.push({
title: info.title,
description: info.description.split('\n')[0],
published: new Date(info.publishedAt),
image: info.thumbnails.default.url,
link: `https://www.youtube.com/watch?v=${info.resourceId.videoId}`
});
}
return items;
}
export async function getContentItems(
fetch: typeof globalThis.fetch,
channelId: string,
blogUrl: string
): Promise<ContentItem[]> {
const latestVideos = await getLatestContent(fetch, channelId);
const blogArticles = await fetchBlogArticles(fetch, blogUrl);
let finalArray = [...latestVideos, ...blogArticles];
finalArray.sort((a, b) => b.published.getTime() - a.published.getTime());
return finalArray.slice(0, 5);
}

View File

@@ -1,7 +1,8 @@
import type { PageServerLoad } from './$types';
import { getLatestPlaylistSong, getLatestWatchedSeries } from '#lib/server/jellyfin';
import { getLatestBook } from '#lib/server/komga';
import { fetchBlogArticles, getChannelInfo } from '#lib/server/content';
import { getContentItems } from '#lib/server/content';
import type { ContentItem } from '#lib/server/content';
import {
JELLYFIN_PLAYLIST_ID,
JELLYFIN_LIBRARY_ID,
@@ -12,21 +13,23 @@ import {
export const load: PageServerLoad = () => {
const latestSong = getLatestPlaylistSong(globalThis.fetch, JELLYFIN_PLAYLIST_ID);
console.log(JELLYFIN_LIBRARY_ID);
const latestSeries = getLatestWatchedSeries(globalThis.fetch, JELLYFIN_LIBRARY_ID);
const latestBook = getLatestBook(globalThis.fetch, KOMGA_LIBRARY_ID);
const blogArticles = fetchBlogArticles(BLOG_URL);
const info = getChannelInfo(CHANNEL_ID);
const contentItems: ContentItem = getContentItems(globalThis.fetch, CHANNEL_ID, BLOG_URL);
latestSong.catch(() => {});
latestSeries.catch(() => {});
latestBook.catch(() => {});
contentItems.catch(() => {});
return {
streamed: {
latestSong,
latestSeries,
latestBook
latestBook,
contentItems
}
};
};

View File

@@ -11,9 +11,9 @@
<div class="absolute aspect-[2/1.732] h-40 text-ctp-surface0">
{@html voidarcIcon}
</div>
<span class="absolute">[VOIDARC INCORPORATED]</span>
<span class="absolute text-ctp-mauve">[VOIDARC INCORPORATED]</span>
</div>
<div class="m-6 mx-auto grid max-w-6xl grid-cols-1 grid-rows-3 gap-5">
<div class="m-6 mx-auto grid max-w-6xl grid-flow-row auto-rows-min gap-5">
<div
class="main-container grid grid-cols-[2fr_1fr] py-7 pl-10"
style="--container-color:var(--ctp-mauve);"
@@ -162,7 +162,11 @@
<div class="grid grid-cols-[4fr_3fr] grid-rows-1 gap-4">
<div class="main-container" style="--container-color:var(--ctp-blue);">
<div class="section-title fira-mono-bold mr-3 py-2 text-4xl">Content</div>
<Content items={['some']} />
{#await data.streamed.contentItems}
<p>Loading latest Content...</p>
{:then items}
<Content {items} />
{/await}
</div>
<div class="main-container" style="--container-color:var(--ctp-green);">
<div class="section-title fira-mono-bold mr-3 py-2 text-4xl">Commits</div>

View File

@@ -1,5 +1,118 @@
<script lang="ts">
let { items } = $props();
import type { ContentItem } from './types';
let { items }: { items: ContentItem[] } = $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: 16,
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>{items[0]}</div>
<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="32"
height={graphHeight}
viewBox={`0 0 32 ${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="3"
class="text-ctp-mauve"
stroke-linecap="round"
/>
{/if}
{/each}
<!-- Commit nodes -->
{#each nodePositions as node}
<circle
cx={node.x}
cy={node.y}
r="10"
fill="#313244"
stroke="currentColor"
stroke-width="3"
class="text-ctp-mauve"
/>
{/each}
</svg>
<!-- Article list -->
<div class="mt-3 mr-4 grid grid-flow-row auto-rows-min">
{#each items as item, index (item.link)}
<div class="relative z-10 grid grid-cols-[2rem_minmax(0,1fr)] gap-4 pb-5">
<!-- Timeline space -->
<div></div>
<!-- Article card -->
<div bind:this={cardElements[index]} class="min-w-0">
<a href={item.link} class="group dynamic-container block bg-ctp-surface1 p-3">
<p class="font-medium group-hover:underline">
{item.title}
</p>
<p class="text-muted-foreground mt-1 text-sm">
{item.description}
</p>
<p class="text-muted-foreground mt-2 text-xs">
{item.published.toLocaleDateString()}
</p>
</a>
</div>
</div>
{/each}
</div>
</div>

View File

@@ -141,6 +141,11 @@
aspect-ratio: 20/5;
}
.dynamic-container {
--container-color: var(--ctp-lavender);
border-left: 5px solid var(--container-color);
}
.text-link {
text-decoration: underline;
color: var(--ctp-blue);