@@ -10,6 +10,7 @@ import {
1010} from ' @/lib/data-utils'
1111import { formatDate } from ' @/lib/utils'
1212import { getThumbnailColors } from ' @/lib/thumbnail-colors'
13+ import { TAG_CLASSES } from ' @/consts'
1314import { Icon } from ' astro-icon/components'
1415import { Image } from ' astro:assets'
1516import type { CollectionEntry } from ' astro:content'
@@ -25,6 +26,23 @@ const readTime = await getCombinedReadingTime(entry.id)
2526const authors = await parseAuthors (entry .data .authors ?? [])
2627const 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 ---------- */
2947const thumb = getThumbnailColors (entry .data ) // ← NEW
3048const 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 ))}
0 commit comments