--- import Layout from '../layouts/Layout.astro'; const API_URL = (typeof process !== 'undefined' ? process.env.PUBLIC_API_URL : import.meta.env.PUBLIC_API_URL) || 'http://localhost:3000'; console.log('Connecting to backend at:', API_URL); interface Post { slug: string; } let posts: Post[] = []; let error = ''; try { const response = await fetch(`${API_URL}/api/posts`); if (response.ok) { posts = await response.json(); } else { error = 'Failed to fetch posts'; } } catch (e) { const cause = (e as any)?.cause; error = `Could not connect to backend at ${API_URL}: ${e instanceof Error ? e.message : String(e)}${cause ? ' (Cause: ' + (cause.message || cause.code || JSON.stringify(cause)) + ')' : ''}`; console.error(error); } function formatSlug(slug: string) { return slug .split('-') .map(word => word.charAt(0).toUpperCase() + word.slice(1)) .join(' '); } ---

Welcome to my blog

Thoughts on software, design, and building things with Rust and Astro.

{error && (
{error}
)} {posts.length === 0 && !error && (

No posts found yet. Add some .md files to the data/posts directory!

)} {posts.map((post) => (

{formatSlug(post.slug)}

{post.excerpt || `Read more about ${formatSlug(post.slug)}...`}

))}