Claude improvements

This commit is contained in:
Andras Schmelczer 2026-05-11 07:48:33 +01:00
parent a86940da30
commit df2267a968
79 changed files with 2695 additions and 1162 deletions

View file

@ -1,8 +1,9 @@
import type { CollectionEntry } from 'astro:content';
import { getCollection } from 'astro:content';
export const site = {
name: 'Andras Schmelczer',
title: 'Andras Schmelczer',
title: 'Andras Schmelczer — Software systems, AI, graphics, simulations, tools',
description:
'Andras Schmelczer writes about software systems, AI deployment, graphics, simulations, and tools.',
url: 'https://schmelczer.dev',
@ -12,6 +13,13 @@ export const site = {
cv: '/media/downloads/cv-andras-schmelczer.pdf',
};
export const navItems = [
{ href: '/', label: 'Home' },
{ href: '/articles/', label: 'Articles' },
{ href: '/projects/', label: 'Projects' },
{ href: '/about/', label: 'About' },
] as const;
export function formatDate(date: Date) {
return new Intl.DateTimeFormat('en', {
year: 'numeric',
@ -20,6 +28,13 @@ export function formatDate(date: Date) {
}).format(date);
}
export function formatDateShort(date: Date) {
return new Intl.DateTimeFormat('en', {
month: 'short',
day: 'numeric',
}).format(date);
}
export function yearOf(date: Date) {
return new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date);
}
@ -44,28 +59,58 @@ export function tagPath(tag: string) {
return `/tags/${tagSlug(tag)}/`;
}
export function formatTag(tag: string) {
return tag;
export function projectAnchor(project: CollectionEntry<'projects'>) {
return project.data.legacyAnchor ?? project.data.sourceProjectId;
}
export function getAllTags(posts: { data: { tags: string[] } }[]) {
export function getAllTags(posts: { data: { tags: readonly string[] } }[]) {
return [...new Set(posts.flatMap((post) => post.data.tags))].sort((a, b) =>
a.localeCompare(b)
);
}
export async function getPublishedPosts() {
export async function getPublishedPosts(): Promise<CollectionEntry<'posts'>[]> {
return (await getCollection('posts'))
.filter((post) => !post.data.draft)
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
}
export async function getProjects() {
export async function getProjects(): Promise<CollectionEntry<'projects'>[]> {
return (await getCollection('projects')).sort(
(a, b) => b.data.sortDate.valueOf() - a.data.sortDate.valueOf()
);
}
export function adjacentPosts(
posts: CollectionEntry<'posts'>[],
current: CollectionEntry<'posts'>
) {
const index = posts.findIndex((post) => post.id === current.id);
if (index === -1) return { previous: undefined, next: undefined };
return {
previous: index < posts.length - 1 ? posts[index + 1] : undefined,
next: index > 0 ? posts[index - 1] : undefined,
};
}
export function getRelatedPosts(
posts: CollectionEntry<'posts'>[],
current: CollectionEntry<'posts'>,
limit = 3
) {
const currentTags = new Set(current.data.tags);
return posts
.filter((post) => post.id !== current.id)
.map((post) => ({
post,
overlap: post.data.tags.filter((tag) => currentTags.has(tag)).length,
}))
.filter(({ overlap }) => overlap > 0)
.sort((a, b) => b.overlap - a.overlap)
.slice(0, limit)
.map(({ post }) => post);
}
export function absoluteUrl(path: string) {
return new URL(path, site.url).toString();
}