Skip to content

Commit cb495c5

Browse files
author
Sadman Hossain
committed
style: add colorful tags & update blog post thumbnail icons
1 parent f4fdcf7 commit cb495c5

File tree

40 files changed

+668
-55
lines changed

40 files changed

+668
-55
lines changed

package-lock.json

Lines changed: 442 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@expressive-code/plugin-collapsible-sections": "^0.40.2",
2323
"@expressive-code/plugin-line-numbers": "^0.40.2",
2424
"@iconify-json/lucide": "^1.2.26",
25+
"@iconify-json/simple-icons": "^1.2.46",
2526
"@iconify-json/tabler": "^1.2.19",
2627
"@swup/astro": "^1.7.0",
2728
"@tailwindcss/vite": "^4.0.7",
@@ -33,6 +34,7 @@
3334
"astro-loader-goodreads": "1.2.1",
3435
"class-variance-authority": "^0.7.1",
3536
"clsx": "^2.1.1",
37+
"jsdom": "^26.1.0",
3638
"limiter": "^3.0.0",
3739
"lucide-react": "^0.469.0",
3840
"medium-zoom": "^1.1.0",
@@ -53,6 +55,8 @@
5355
},
5456
"devDependencies": {
5557
"@iconify-icons/tabler": "^1.2.95",
58+
"@iconify-json/clarity": "^1.2.2",
59+
"@types/jsdom": "^21.1.7",
5660
"@types/xml2js": "^0.4.14",
5761
"prettier": "^3.5.1",
5862
"prettier-plugin-astro": "^0.14.1",

src/components/BlogCard.astro

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '@/lib/data-utils'
1111
import { formatDate } from '@/lib/utils'
1212
import { getThumbnailColors } from '@/lib/thumbnail-colors'
13+
import { TAG_CLASSES } from '@/consts'
1314
import { Icon } from 'astro-icon/components'
1415
import { Image } from 'astro:assets'
1516
import type { CollectionEntry } from 'astro:content'
@@ -25,6 +26,23 @@ const readTime = await getCombinedReadingTime(entry.id)
2526
const authors = await parseAuthors(entry.data.authors ?? [])
2627
const subpostCount = !isSubpost(entry.id) ? await getSubpostCount(entry.id) : 0
2728
29+
/* ---------- tag styling helper ---------- */
30+
const getTagClasses = (tag: string) => {
31+
const tagLower = tag.toLowerCase()
32+
// Check for exact matches first
33+
if (TAG_CLASSES[tagLower]) {
34+
return TAG_CLASSES[tagLower]
35+
}
36+
// Check for partial matches
37+
for (const [key, classes] of Object.entries(TAG_CLASSES)) {
38+
if (tagLower.includes(key)) {
39+
return classes
40+
}
41+
}
42+
// Default classes
43+
return 'flex items-center gap-x-1 text-xs'
44+
}
45+
2846
/* ---------- visual theming ---------- */
2947
const thumb = getThumbnailColors(entry.data) // ← NEW
3048
const card = (() => {
@@ -70,8 +88,8 @@ const cssVars = {
7088
class="flex flex-col gap-4 sm:flex-row"
7189
>
7290
{(entry.data.thumbnailIcon || entry.data.image) && (
73-
<div class="relative max-w-[200px] sm:flex-shrink-0">
74-
<div class="h-[55px] w-[80px] rounded-xl flex items-center justify-center thumbnail">
91+
<div class="relative max-w-[180px] sm:flex-shrink-0">
92+
<div class="h-[55px] w-[70px] rounded-xl flex items-center justify-center thumbnail">
7593
<Icon
7694
name={entry.data.thumbnailIcon || 'lucide:file-text'}
7795
class={`thumbnail-icon ${entry.data.thumbnailIconSize || 'h-10 w-10'}`}
@@ -109,7 +127,10 @@ const cssVars = {
109127
<Separator orientation="vertical" className="h-4!" />
110128
<div class="flex flex-wrap gap-1">
111129
{entry.data.tags.map((tag) => (
112-
<Badge variant="muted" className="flex items-center gap-x-1 text-xs">
130+
<Badge
131+
variant="muted"
132+
classes={getTagClasses(tag)}
133+
>
113134
{tag}
114135
</Badge>
115136
))}

src/components/ui/badge.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ function Badge({
3131
className,
3232
variant,
3333
asChild = false,
34+
classes,
3435
...props
3536
}: React.ComponentProps<'span'> &
36-
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
37+
VariantProps<typeof badgeVariants> & { asChild?: boolean; classes?: string }) {
3738
const Comp = asChild ? SlotPrimitive.Root : 'span'
3839

40+
const finalClasses = classes || className
41+
3942
return (
4043
<Comp
4144
data-slot="badge"
42-
className={cn(badgeVariants({ variant }), className)}
45+
className={cn(badgeVariants({ variant }), finalClasses)}
4346
{...props}
4447
/>
4548
)

src/components/ui/more-dropdown.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ const menuItems = [
193193
updateTextWithCrossFade();
194194
}, 1000);
195195

196-
// Set interval to change text every 13 seconds
197-
const intervalId = setInterval(updateTextWithCrossFade, 13000);
196+
// Set interval to change text every 20 seconds
197+
const intervalId = setInterval(updateTextWithCrossFade, 20000);
198198

199199
// Dropdown functionality
200200
if (trigger && content) {

src/consts.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,17 @@ export const FEATURED_PROJECTS = [
6767
'astro-loader-goodreads/astro-loader-goodreads',
6868
'fricdl/fricdl',
6969
'libstreetmap/libstreetmap',
70-
];
70+
]
71+
72+
export const TAG_CLASSES: Record<string, string> = {
73+
uoft:
74+
'bg-blue-300 text-primary dark:bg-blue-800 dark:text-white flex items-center gap-x-1 text-xs',
75+
personal: 'bg-purple-200 text-secondary-foreground dark:bg-purple-900 dark:text-white flex items-center gap-x-1 text-xs',
76+
advice: 'bg-lime-200 text-secondary-foreground dark:bg-lime-900 dark:text-white flex items-center gap-x-1 text-xs',
77+
project:
78+
'bg-purple-500 text-white hover:bg-purple-600 flex items-center gap-x-1 text-xs',
79+
tutorial:
80+
'bg-orange-200 text-secondary-foreground dark:bg-orange-900 dark:text-white flex items-center gap-x-1 text-xs',
81+
analysis:
82+
'bg-indigo-500 text-white hover:bg-indigo-600 flex items-center gap-x-1 text-xs',
83+
}

src/content/blog/2020-08-17-on-keeping-a-journal/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: 'On keeping a journal'
33
description: "Why you should be writing if you aren't already."
44
date: 2020-08-17
5-
tags: ['writing']
5+
tags: ['advice', 'writing']
66
slug: on-keeping-a-journal
77
authors: ['sadman']
88
---

src/content/blog/2020-09-25-coming-up-with-good-ideas/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Coming up with (good) ideas
33
description: "Coming up with good ideas can be tough, but the real magic lies in the process, not just the outcome."
44
date: 2020-09-25
55
slug: "coming-up-with-good-ideas"
6-
tags: ['writing']
6+
tags: ['advice', 'writing']
77
authors: ['sadman']
88
---
99

src/content/blog/2020-11-09-why-i-use-trello/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Why I use Trello"
33
description: "Everybody needs a system for making their to do list; Trello is mine."
44
date: 2020-11-09
55
slug: "why-i-use-trello"
6-
tags: ['productivity', 'tools']
6+
tags: ['advice', 'productivity', 'tools']
77
authors: ['sadman']
88
---
99

src/content/blog/2020-12-14-a-guide-to-learning/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "A guide to learning"
33
description: "Better alternatives to rote memorization (also known as cramming the night before an exam)"
44
date: 2020-12-14
55
slug: "a-guide-to-learning"
6-
tags: ['learning', 'university']
6+
tags: ['advice', 'learning', 'university']
77
authors: ['sadman']
88
---
99

0 commit comments

Comments
 (0)