Samuel Shuert | 86826b8 | 2024-04-27 16:14:20 -0400 | [diff] [blame] | 1 | --- |
| 2 | import BaseHead from '../components/BaseHead.astro'; |
Samuel Shuert | 86826b8 | 2024-04-27 16:14:20 -0400 | [diff] [blame] | 3 | import Footer from '../components/Footer.astro'; |
| 4 | import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'; |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 5 | import { getCollection } from 'astro:content'; |
| 6 | import FormattedDate from '../components/FormattedDate.astro'; |
| 7 | |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 8 | |
| 9 | const posts = await getCollection('post') |
| 10 | |
| 11 | const pinnedPosts = posts.filter(p => p.data.pinned); |
| 12 | const otherPosts = posts.filter(p => !(p.data.pinned || false)) |
| 13 | |
Samuel Shuert | 86826b8 | 2024-04-27 16:14:20 -0400 | [diff] [blame] | 14 | --- |
| 15 | |
| 16 | <!doctype html> |
| 17 | <html lang="en"> |
| 18 | <head> |
| 19 | <BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} /> |
| 20 | </head> |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 21 | <body class="bg-mantle min-h-screen flex flex-col items-center"> |
| 22 | <div class="flex justify-center w-full flex-col gap-2 md:min-w-[768px] px-4 md:max-w-screen-lg"> |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 23 | <nav class="bg-mantle flex justify-center py-2 h-12"> |
| 24 | <div class="flex flex-col items-center group"> |
| 25 | <a href="/" class="text-text cursor-pointer hover:bg-surface0 rounded px-4 transition-colors"> |
| 26 | Home |
| 27 | </a> |
| 28 | <div class="bg-text h-[2px] w-8 -mt-1 rounded-full group-hover:w-10 transition-all" /> |
| 29 | </div> |
| 30 | </nav> |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 31 | <main class="w-full bg-mantle mt-6 min-h-[84vh]"> |
| 32 | <section id="posts"> |
| 33 | <div class="flex flex-wrap gap-4 justify-center mb-10"> |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 34 | { |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 35 | pinnedPosts.length > 0 ? pinnedPosts.map((post) => ( |
| 36 | <a href={`/post/${post.slug}/`} class=" |
| 37 | h-32 text-base bg-base p-4 rounded-2xl flex flex-col flex-grow border border-blue |
| 38 | hover:bg-surface0 hover:-translate-y-2 transition-all"> |
| 39 | <h4 class="text-text w-full text-ellipsis">{post.data.title}</h4> |
| 40 | <div class="text-subtext0 flex"> |
| 41 | <p title="Pinned">📌 </p> |
| 42 | <FormattedDate date={post.data.pubDate} /> |
| 43 | </div> |
| 44 | </a> |
| 45 | )) : null |
| 46 | } |
| 47 | </div> |
| 48 | <div class="flex flex-wrap gap-4 justify-center"> |
| 49 | { |
| 50 | otherPosts.length > 0 ? otherPosts.map((post, idx) => ( |
| 51 | <a href={`/post/${post.slug}/`} class=" |
| 52 | h-32 text-base bg-base p-4 rounded-2xl flex flex-col flex-grow |
| 53 | first:text-center first:text-xl first:border-yellow first:border first:box-border |
| 54 | first:max-md:text-left first:max-md:w-full |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 55 | hover:bg-surface0 hover:-translate-y-2 transition-all |
| 56 | max-md:w-full"> |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 57 | <h4 class="text-text w-full text-ellipsis">{post.data.title}</h4> |
| 58 | <div class="text-subtext0 flex"> |
| 59 | { idx === 0 ? <p title="Latest">✨ </p> : null } |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 60 | <FormattedDate date={post.data.pubDate} /> |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 61 | </div> |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 62 | </a> |
Samuel Shuert | 21af95a | 2024-04-30 17:49:11 -0400 | [diff] [blame^] | 63 | )) : null |
| 64 | } |
| 65 | </div> |
| 66 | <div class="flex justify-center h-40"> |
| 67 | { |
| 68 | posts.length === 0 ? |
| 69 | <div class="border border-dashed border-surface0 rounded-xl flex justify-center items-center w-1/2"> |
| 70 | No Posts Yet |
| 71 | </div> : |
| 72 | null |
Samuel Shuert | 3963283 | 2024-04-29 20:54:19 -0400 | [diff] [blame] | 73 | } |
| 74 | </div> |
| 75 | </section> |
| 76 | </main> |
| 77 | </div> |
Samuel Shuert | 86826b8 | 2024-04-27 16:14:20 -0400 | [diff] [blame] | 78 | <Footer /> |
| 79 | </body> |
| 80 | </html> |