From 622aa6ea268ec804c101825db4c9bac0459be331 Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Sat, 25 Feb 2023 21:25:27 +0700 Subject: [PATCH 1/3] chore: add utils/date --- src/utils/date.ts | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/utils/date.ts diff --git a/src/utils/date.ts b/src/utils/date.ts new file mode 100644 index 00000000..5548f013 --- /dev/null +++ b/src/utils/date.ts @@ -0,0 +1 @@ +export const formatDate = (date: string | Date) => (date instanceof Date ? date : new Date(date)).toLocaleString('en-US', { day: 'numeric', month: 'long', year: 'numeric' }) From b0425c15ab17e43515bdfd2c5934ecbd437004fe Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Sat, 25 Feb 2023 21:27:00 +0700 Subject: [PATCH 2/3] fix(component): adjust background color for LeetCode difficulty --- src/components/LeetCodeDifficulty.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/LeetCodeDifficulty.astro b/src/components/LeetCodeDifficulty.astro index 19f6908a..0140e876 100644 --- a/src/components/LeetCodeDifficulty.astro +++ b/src/components/LeetCodeDifficulty.astro @@ -37,7 +37,7 @@ const getDifficultyCssClass: (difficulty: string) => string = ( @apply border-2; @apply border-difficulty-#{$difficulty}; @apply text-difficulty-#{$difficulty}; - @apply hover:bg-transparent; + @apply hover:bg-site-bg; @apply hover:border-difficulty-#{$difficulty}-hover; @apply hover:text-difficulty-#{$difficulty}-hover; } From 9b4a99d910d90b575950f9612e10fae866d0d92e Mon Sep 17 00:00:00 2001 From: Le Minh Tri Date: Sat, 25 Feb 2023 21:27:39 +0700 Subject: [PATCH 3/3] feat(component): add component PostHeader --- src/components/post/PostHeader.astro | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/components/post/PostHeader.astro diff --git a/src/components/post/PostHeader.astro b/src/components/post/PostHeader.astro new file mode 100644 index 00000000..26604aa9 --- /dev/null +++ b/src/components/post/PostHeader.astro @@ -0,0 +1,52 @@ +--- +import type { CollectionEntry } from 'astro:content' +import kebabCase from 'lodash.kebabcase' + +import LeetCodeDifficulty from '@/components/LeetCodeDifficulty.astro' +import siteConfig from '@/configs/site' +import { formatDate } from '@/utils/date' + +type Props = CollectionEntry<'leetcode-solutions'>['data'] + +const { author: siteAuthor } = siteConfig +const { title, author, pubDate, tags = [], difficulty } = Astro.props + +const formattedDate = formatDate(pubDate) +--- + +
+

{title}

+
+ +
+
+ { + tags.map((tag) => ( + + + {tag} + + + )) + } +
+
+ Author's avatar +
+ {author} + Posted on {formattedDate} +
+
+
+ +