feat: refactor blog components

This commit is contained in:
2026-02-16 22:26:53 -06:00
parent 505670dbf8
commit 6423ffba63
25 changed files with 476 additions and 460 deletions

View File

@@ -0,0 +1,58 @@
---
import { Icon } from 'astro-icon/components';
import type { Post } from '@lib/directusTypes';
import Image from '@components/ui/images/Image.astro';
import { getDirectusImageURL } from '@lib/directusFunctions';
interface Props {
post: Post;
}
const { post } = Astro.props;
---
<div class="smooth-reveal-cards group flex flex-col">
<a
class="card-base"
href={`/blog/${post.slug}/`}
data-astro-prefetch
>
<div class="relative shrink-0 rounded-t-xl w-full overflow-hidden before:absolute before:inset-x-0 before:z-1 before:size-full">
<Image
class="rounded-t-xl h-auto w-full"
src={getDirectusImageURL(post.image)}
alt={post.image_alt}
draggable="false"
loading="eager"
format="webp"
/>
</div>
<div class="rounded-xl p-4 md:p-5">
<h3 class="card-text-title text-xl">
{post.title}
</h3>
<div class="ml-6 flex">
<div class="relative inline-block w-full">
<div class="card-text-title card-hover-text-title flex relative items-center mx-auto min-h-11 sm:mx-0 sm:mt-4">
<span class="relative inline-block overflow-hidden ml-2">
Read more
</span>
<Icon
name="mdi:keyboard-arrow-right"
class="translate-y-0.5 transition duration-300 group-hover:translate-x-1"
/>
<p class="card-text-description text-sm ml-auto">
{new Date(post.published_date).toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric',
})}
</p>
</div>
</div>
</div>
</div>
</a>
</div>

View File

@@ -0,0 +1,63 @@
---
interface Props {
slug: string;
title: string;
description: string;
count: number;
publishDate: string;
}
const { slug, title, description, count, publishDate } = Astro.props;
---
<div class="smooth-reveal-cards group h-full">
<a
class="card-base flex flex-col h-full min-h-55"
href={`/categories/${slug}/`}
data-astro-prefetch
>
<div class="relative grow overflow-hidden">
<div class="absolute inset-1 flex flex-col p-3 md:p-4 lg:p-5">
<div class="overflow-hidden">
<h3 class="card-text-title-major card-hover-text-title whitespace-nowrap mb-4">
{title}
</h3>
<p class="card-text-description mb-4">
{description}
</p>
</div>
<div class="card-text-description flex items-center justify-between text-xs mt-auto pt-1 md:pt-2">
<span class="inline-flex items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
class="mr-1"
>
<path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"></path>
</svg>
{count}
</span>
<span class="inline-flex items-center">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
class="mr-1"
>
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
{publishDate}
</span>
</div>
</div>
</div>
</a>
</div>

View File

@@ -9,13 +9,11 @@ interface Props {
}
const { title, description, url, icon } = Astro.props;
const sizeClasses = 'h-30 w-100 md:w-[300px]';
---
<div class="smooth-reveal-2 group flex flex-col">
<a
class={`card-base flex items-center ${sizeClasses}`}
class="card-base flex items-center h-30 w-100 md:w-75"
href={url}
data-astro-prefetch
>
@@ -29,9 +27,9 @@ const sizeClasses = 'h-30 w-100 md:w-[300px]';
<span class="card-text-title card-hover-text-title block text-lg">
{title}
</span>
<span class="card-text-description block mt-1">
<p class="card-text-description block mt-1">
{description}
</span>
</p>
</div>
</div>
</div>

View File

@@ -39,9 +39,9 @@ const visitClass = visitSource ? 'card-hover-text-gitea' : 'card-hover-text-titl
<span class="card-text-title block text-lg">
{title}
</span>
<span class="card-text-description block mt-1">
<p class="card-text-description block mt-1">
{description}
</span>
</p>
</div>
</div>
{highlights && (
@@ -55,7 +55,7 @@ const visitClass = visitSource ? 'card-hover-text-gitea' : 'card-hover-text-titl
)}
<div class="ml-6 flex">
<div class="relative inline-block">
<div class={`card-text-title ${visitClass} flex relative items-center mx-auto min-h-11 font-semibold text-md sm:mx-0 sm:mt-4`}>
<div class={`card-text-title ${visitClass} flex relative items-center font-semibold text-md min-h-11 mx-auto sm:mx-0 sm:mt-4`}>
{visitSource && <Icon name="pajamas:gitea" />}
<span class="relative inline-block overflow-hidden ml-2">
{visitText}

View File

@@ -0,0 +1,54 @@
---
import { Icon } from 'astro-icon/components';
import Image from '@components/ui/images/Image.astro';
interface Props {
title: string;
subTitle: string;
url?: string;
img: any;
imgAlt: any;
}
const { title, subTitle, url, img, imgAlt } = Astro.props;
---
<div class="smooth-reveal group">
<a
class="card-base-hidden md:grid md:grid-cols-2 lg:grid lg:grid-cols-2 items-center gap-8 xl:gap-16 max-w-340 2xl:max-w-full px-4 sm:px-6 lg:px-8 py-10 sm:py-16 lg:py-14 mx-auto"
href={url}
data-astro-prefetch
>
<div>
<Image
class="rounded-xl w-full h-full sm:max-h-80 md:max-h-90 object-cover"
src={img}
alt={imgAlt}
draggable="false"
loading="lazy"
width="850"
height="420"
/>
</div>
<div>
<h2 class="card-text-header mb-4">
{title}
</h2>
<p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-4">
{subTitle}
</p>
<div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2">
<div class="button-text-title flex relative items-center text-center">
<span class="mr-2">
Read More
</span>
<Icon
name="mdi:keyboard-arrow-right"
class="button-hover-arrow"
/>
</div>
</div>
</div>
</a>
</div>

View File

@@ -0,0 +1,82 @@
---
import { Icon } from 'astro-icon/components';
import Image from '@components/ui/images/Image.astro';
interface Props {
title: string;
subTitle: string;
url?: string;
single?: boolean;
imgOne?: any;
imgOneAlt?: any;
imgTwo?: any;
imgTwoAlt?: any;
}
const { title, subTitle, url, single, imgOne, imgOneAlt, imgTwo, imgTwoAlt } = Astro.props;
---
<div class="smooth-reveal group">
<a
class="card-base-hidden items-center lg:grid lg:grid-cols-2 gap-16 max-w-340 2xl:max-w-full px-4 py-10 sm:px-6 lg:px-8 lg:py-14 mx-auto"
href={url}
data-astro-prefetch
>
<div>
<h2 class="card-text-header mb-4">
{title}
</h2>
<p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-4">
{subTitle}
</p>
<div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2">
<div class="button-text-title flex relative items-center text-center">
<span class="mr-2">
Read More
</span>
<Icon
name="mdi:keyboard-arrow-right"
class="button-hover-arrow"
/>
</div>
</div>
</div>
{single ? (
<div>
<Image
class="rounded-xl w-full"
src={imgOne}
alt={imgOneAlt}
format="webp"
loading="lazy"
width="850"
height="420"
/>
</div>
) : (
<div class="grid grid-cols-2 gap-4">
<Image
class="rounded-xl w-full"
src={imgOne}
alt={imgOneAlt}
draggable="false"
format="webp"
loading="lazy"
width="400"
height="230"
/>
<Image
class="rounded-xl w-full mt-4 lg:mt-10"
src={imgTwo}
alt={imgTwoAlt}
draggable="false"
format="webp"
loading="lazy"
width="400"
height="230"
/>
</div>
)}
</a>
</div>

View File

@@ -7,12 +7,10 @@ interface Props {
}
const { dayName, label, icon, temp } = Astro.props;
const sizeClasses = 'w-32 md:w-40';
---
<div class="smooth-reveal-2 group flex flex-col">
<div class={`card-base ${sizeClasses}`}>
<div class="card-base w-32 md:w-40">
<div class="p-5 text-center">
<span class="card-text-description block font-bold text-xs uppercase tracking-widest">
{dayName}