diff --git a/src/components/cards/BlogCard.astro b/src/components/cards/BlogCard.astro index 5d51baf..7514d8a 100644 --- a/src/components/cards/BlogCard.astro +++ b/src/components/cards/BlogCard.astro @@ -1,11 +1,9 @@ --- import { Image } from 'astro:assets'; -import getReadingTime from 'reading-time'; import type { Post } from '@lib/directusTypes'; -import Logo from '@components/images/Logo.astro'; -import { formatShortDate } from '@support/time'; +import PostMetadataSnippet from '@/components/snippets/PostMetadataSnippet.astro'; import { getDirectusImageURL } from '@/support/url'; interface Props { @@ -13,8 +11,6 @@ interface Props { } const { post } = Astro.props; - -const readingTime = getReadingTime(post.content || ''); ---
@@ -36,35 +32,15 @@ const readingTime = getReadingTime(post.content || '');
-

+

{post.title}

-
-
-
- -
- {post.category.title} -
- - / - -

- {formatShortDate(post.published_date)} -

- - / - - - {readingTime.minutes.toPrecision(1)} minutes - +
+
diff --git a/src/components/cards/LargeBlogLeftCard.astro b/src/components/cards/LargeBlogLeftCard.astro index c7d4406..658981e 100644 --- a/src/components/cards/LargeBlogLeftCard.astro +++ b/src/components/cards/LargeBlogLeftCard.astro @@ -1,12 +1,10 @@ --- import { Image } from 'astro:assets'; -import getReadingTime from 'reading-time'; import type { Post } from '@lib/directusTypes'; import ReadMoreButton from '@components/buttons/ReadMoreButton.astro'; -import Logo from '@components/images/Logo.astro'; -import { formatShortDate } from '@support/time'; +import PostMetadataSnippet from '@/components/snippets/PostMetadataSnippet.astro'; import { getDirectusImageURL } from '@/support/url'; interface Props { @@ -14,8 +12,6 @@ interface Props { } const { post } = Astro.props; - -const readingTime = getReadingTime(post.content || ''); ---
@@ -26,51 +22,32 @@ const readingTime = getReadingTime(post.content || ''); >
{post.image_alt}
-
-

+
+

{post.title}

-

+

{post.description}

-
- -
-
-
- -
- {post.category.title} -
- - / - -

- {formatShortDate(post.published_date)} -

- - / - - - {readingTime.minutes.toPrecision(1)} minutes - +
+ +
+
+
diff --git a/src/components/cards/LargeBlogRightCard.astro b/src/components/cards/LargeBlogRightCard.astro index 1bab72f..91121af 100644 --- a/src/components/cards/LargeBlogRightCard.astro +++ b/src/components/cards/LargeBlogRightCard.astro @@ -1,12 +1,10 @@ --- import { Image } from 'astro:assets'; -import getReadingTime from 'reading-time'; import type { Post } from '@lib/directusTypes'; import ReadMoreButton from '@components/buttons/ReadMoreButton.astro'; -import Logo from '@components/images/Logo.astro'; -import { formatShortDate } from '@support/time'; +import PostMetadataSnippet from '@/components/snippets/PostMetadataSnippet.astro'; import { getDirectusImageURL } from '@/support/url'; interface Props { @@ -14,8 +12,6 @@ interface Props { } const { post } = Astro.props; - -const readingTime = getReadingTime(post.content || ''); ---
@@ -24,40 +20,22 @@ const readingTime = getReadingTime(post.content || ''); href={`/blog/${post.slug}`} data-astro-prefetch > -
-

+
+

{post.title}

-

+

{post.description}

-
- -
-
-
- -
- {post.category.title} -
- - / - -

- {formatShortDate(post.published_date)} -

- - / - - - {readingTime.minutes.toPrecision(1)} minutes - +
+ +
+
@@ -69,8 +47,6 @@ const readingTime = getReadingTime(post.content || ''); alt={post.image_alt} draggable="false" loading="lazy" - width="850" - height="420" inferSize={true} />
@@ -83,8 +59,6 @@ const readingTime = getReadingTime(post.content || ''); alt={post.image_alt} draggable="false" loading="lazy" - width="850" - height="420" inferSize={true} />
@@ -95,8 +69,6 @@ const readingTime = getReadingTime(post.content || ''); alt={post.image_alt} draggable="false" loading="lazy" - width="600" - height="310" inferSize={true} /> {post.image_second_alt}

diff --git a/src/components/snippets/PostMetadataSnippet.astro b/src/components/snippets/PostMetadataSnippet.astro index 61173d9..5ea4c81 100644 --- a/src/components/snippets/PostMetadataSnippet.astro +++ b/src/components/snippets/PostMetadataSnippet.astro @@ -4,57 +4,78 @@ import getReadingTime from 'reading-time'; import type { Post } from '@lib/directusTypes'; import Logo from '@components/images/Logo.astro'; -import { formatShortDate } from '@support/time'; +import { formatShortDate, formatDate } from '@support/time'; import { getDirectusImageURL } from '@/support/url'; interface Props { post: Post; + enableCategoryLink?: boolean; + dateFormat?: 'short' | 'long'; } -const { post } = Astro.props; +const { post, enableCategoryLink = true, dateFormat = 'short' } = Astro.props; const readingTime = getReadingTime(post.content || ''); --- -
-
    - {post.category && ( -
  1. - - + + ) : ( +
    +
    +
    + +
    + {post.category.title} +
    +
    )} -
  2. - - {formatShortDate(post.published_date)} - - - / - -
  3. -
  4. - - {readingTime.minutes.toPrecision(1)} minutes - -
  5. -
-
\ No newline at end of file + + )} +
  • + + / + +
  • +
  • + + {dateFormat === 'short' ? formatShortDate(post.published_date) : formatDate(post.published_date)} + +
  • +
  • + + / + +
  • +
  • + + {readingTime.minutes.toPrecision(1)} minutes + +
  • + diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 5c28972..ac2e6fd 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -96,7 +96,12 @@ const content = marked.parse(post.content || '');

    {post.title}

    - +
    + +
    diff --git a/src/styles/utilities.css b/src/styles/utilities.css index 2fd2b84..52a97b5 100644 --- a/src/styles/utilities.css +++ b/src/styles/utilities.css @@ -127,6 +127,11 @@ @apply text-secondary } +@utility card-hover-text-description { + @apply transition-all duration-300 + text-secondary-hover +} + /* Misc */ @utility nav-base { @apply border border-neutral-100 dark:border-stone-500/20