|
| 1 | +--- |
| 2 | +import Card from "../components/Card.astro"; |
| 3 | +import config from "../config"; |
| 4 | +import Layout from "../layouts/Layout.astro"; |
| 5 | +
|
| 6 | +if (!import.meta.env.DEV) { |
| 7 | + return Astro.redirect("/404"); |
| 8 | +} |
| 9 | +
|
| 10 | +const database = { |
| 11 | + title: "Astrotion", |
| 12 | + description: "A collection of thoughts, ideas, and discoveries about technology, design, and life.", |
| 13 | +}; |
| 14 | +
|
| 15 | +const posts = [ |
| 16 | + { |
| 17 | + title: "Getting Started with Astro", |
| 18 | + excerpt: "Learn how to build blazingly fast websites with Astro, the modern static site generator that ships zero JavaScript by default.", |
| 19 | + image: "https://images.unsplash.com/photo-1517694712202-14dd9538aa97?w=800&h=450&fit=crop", |
| 20 | + date: "2025-01-15", |
| 21 | + slug: "getting-started-with-astro", |
| 22 | + }, |
| 23 | + { |
| 24 | + title: "The Art of Minimalist Design", |
| 25 | + excerpt: "Exploring the principles of minimalist design and how less can truly be more when creating memorable user experiences.", |
| 26 | + image: "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&h=450&fit=crop", |
| 27 | + date: "2025-01-12", |
| 28 | + slug: "minimalist-design", |
| 29 | + }, |
| 30 | + { |
| 31 | + title: "Building a Second Brain", |
| 32 | + excerpt: "A practical guide to organizing your digital life and creating a personal knowledge management system that actually works.", |
| 33 | + image: "https://images.unsplash.com/photo-1456324504439-367cee3b3c32?w=800&h=450&fit=crop", |
| 34 | + date: "2025-01-10", |
| 35 | + slug: "second-brain", |
| 36 | + }, |
| 37 | + { |
| 38 | + title: "Remote Work Best Practices", |
| 39 | + excerpt: "Tips and strategies for staying productive and maintaining work-life balance while working from anywhere in the world.", |
| 40 | + image: "https://images.unsplash.com/photo-1522202176988-66273c2fd55f?w=800&h=450&fit=crop", |
| 41 | + date: "2025-01-08", |
| 42 | + slug: "remote-work", |
| 43 | + }, |
| 44 | + { |
| 45 | + title: "Introduction to TypeScript", |
| 46 | + excerpt: "Why TypeScript is becoming the go-to choice for JavaScript developers and how to get started with type-safe coding.", |
| 47 | + image: "https://images.unsplash.com/photo-1555066931-4365d14bab8c?w=800&h=450&fit=crop", |
| 48 | + date: "2025-01-05", |
| 49 | + slug: "intro-typescript", |
| 50 | + }, |
| 51 | + { |
| 52 | + title: "Mastering CSS Grid Layout", |
| 53 | + excerpt: "A comprehensive guide to CSS Grid, the powerful layout system that makes complex web layouts simple and intuitive.", |
| 54 | + image: "https://images.unsplash.com/photo-1507721999472-8ed4421c4af2?w=800&h=450&fit=crop", |
| 55 | + date: "2025-01-03", |
| 56 | + slug: "css-grid", |
| 57 | + }, |
| 58 | +]; |
| 59 | +
|
| 60 | +const formatDate = (dateStr: string) => { |
| 61 | + return new Date(dateStr).toLocaleDateString("en-US", { |
| 62 | + year: "numeric", |
| 63 | + month: "long", |
| 64 | + day: "numeric", |
| 65 | + }); |
| 66 | +}; |
| 67 | +--- |
| 68 | + |
| 69 | +<Layout database={database}> |
| 70 | + <main class="py-12 lg:py-20"> |
| 71 | + <article class="max-w-6xl mx-auto px-3"> |
| 72 | + <header class="text-center mb-12"> |
| 73 | + <h1 class:list={["mb-12 text-6xl title", config.index?.titleClasses]}> |
| 74 | + {database.title} |
| 75 | + </h1> |
| 76 | + <p class="mx-auto max-w-xl"> |
| 77 | + {database.description} |
| 78 | + </p> |
| 79 | + </header> |
| 80 | + <section class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 py-8"> |
| 81 | + { |
| 82 | + posts.map((post) => ( |
| 83 | + <Card |
| 84 | + href={`/posts/${post.slug}`} |
| 85 | + title={post.title} |
| 86 | + body={post.excerpt} |
| 87 | + image={post.image} |
| 88 | + date={formatDate(post.date)} |
| 89 | + /> |
| 90 | + )) |
| 91 | + } |
| 92 | + </section> |
| 93 | + </article> |
| 94 | + </main> |
| 95 | +</Layout> |
| 96 | +<style |
| 97 | + define:vars={{ |
| 98 | + titleFontFamily: config.index?.titleFontFamily || "inherit", |
| 99 | + }} |
| 100 | +> |
| 101 | + .title { |
| 102 | + font-family: var(--titleFontFamily); |
| 103 | + } |
| 104 | +</style> |
0 commit comments