File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11---
2+ import FormattedDate from ' @/components/FormattedDate.astro' ;
23import PageLayout from ' @/layouts/PageLayout.astro' ;
4+ import { getCollection } from ' astro:content' ;
35
4- return Astro .redirect (' /blog' );
6+ const posts = (await getCollection (' blog' )).sort (
7+ (a , b ) => b .data .pubDate .valueOf () - a .data .pubDate .valueOf ()
8+ );
59---
610
7- <PageLayout title =" Home" />
11+ <PageLayout title =" Home" >
12+ <ul >
13+ {
14+ posts .map ((post ) => (
15+ <li class = " py-5" >
16+ <article >
17+ <a
18+ href = { ` /blog/${post .slug }/ ` }
19+ class = " hover:text-emerald-600 flex flex-col gap-1"
20+ >
21+ <h2 class = " text-3xl font-bold" >{ post .data .title } </h2 >
22+ <p class = " text-gray-500 text-sm" >
23+ <span >
24+ 작성일:
25+ <FormattedDate datetime = { post .data .pubDate } />
26+ </span >
27+ { post .data .updatedDate && (
28+ <span >
29+ 수정일:
30+ <FormattedDate datetime = { post .data .updatedDate } />
31+ </span >
32+ )}
33+ </p >
34+ <p class = " text-slate-500" >{ post .data .description } </p >
35+ </a >
36+ </article >
37+ </li >
38+ ))
39+ }
40+ </ul >
41+ </PageLayout >
You can’t perform that action at this time.
0 commit comments