File tree 5 files changed +46
-5
lines changed
5 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,14 @@ import React from "react";
2
2
import { format } from "date-fns" ;
3
3
import Link from "next/link" ;
4
4
import { CalendarIcon } from "./icons/CalendarIcon" ;
5
+ import { Tag } from "@components/Tag" ;
5
6
6
7
interface ArticleBlockProps {
7
8
slug : string ;
8
9
title : string ;
9
10
description ?: string ;
10
11
date : string ;
11
- tags ? : string [ ] ;
12
+ tags : string [ ] ;
12
13
}
13
14
14
15
export default function ArticleBlock ( {
@@ -25,8 +26,17 @@ export default function ArticleBlock({
25
26
< h2 > { title } </ h2 >
26
27
</ Link >
27
28
< p > { description } </ p >
28
- < span className = "art-date" > < CalendarIcon /> { formattedDate } </ span >
29
-
29
+ { tags . length != 0 ? (
30
+ < div className = "tags" >
31
+ { tags ?. map ( ( tag ) => (
32
+ < Tag > { tag } </ Tag >
33
+ ) ) }
34
+ </ div >
35
+ ) : null }
36
+ < span className = "art-date" >
37
+ < CalendarIcon />
38
+ { formattedDate }
39
+ </ span >
30
40
</ article >
31
41
) ;
32
42
}
Original file line number Diff line number Diff line change
1
+ import Link from "next/link" ;
2
+ import { slug } from "github-slugger" ;
3
+
4
+ interface TagProps {
5
+ children : string ;
6
+ }
7
+ export function Tag ( { children } : TagProps ) {
8
+ return < span className = "tag" > { children } </ span > ;
9
+ }
Original file line number Diff line number Diff line change 7
7
@forward " toc-links" ;
8
8
@forward " info-box" ;
9
9
@forward " recipe-info" ;
10
- @forward " article-block" ;
10
+ @forward " article-block" ;
11
+ @forward " tag" ;
Original file line number Diff line number Diff line change
1
+ @use " ../abstracts" as * ;
2
+
3
+ .tags {
4
+ display : flex ;
5
+ flex-wrap : wrap ;
6
+ gap : 0.5rem ;
7
+ }
8
+
9
+ .tag {
10
+ cursor : pointer ;
11
+ font-family : $font-bold ;
12
+ font-size : 0.8rem ;
13
+ display : inline-block ;
14
+ padding : 0.25em 0.8em ;
15
+ border-radius : 0.7em ;
16
+ background-color : var (--collapsible-bg );
17
+
18
+ & :hover {
19
+ background-color : var (--collapsible-summary-bg );
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ const posts = defineCollection({
64
64
description : s . string ( ) . max ( 200 ) . optional ( ) ,
65
65
date : s . isodate ( ) ,
66
66
published : s . boolean ( ) . default ( true ) ,
67
- tags : s . array ( s . string ( ) ) . optional ( ) ,
67
+ tags : s . array ( s . string ( ) ) . default ( [ ] ) ,
68
68
body : s . mdx ( ) ,
69
69
} )
70
70
. transform ( postComputedFields ) ,
You can’t perform that action at this time.
0 commit comments