Initial rewrite
This commit is contained in:
parent
a5f64a3ff8
commit
0d183c8335
200 changed files with 12537 additions and 18659 deletions
49
src/components/ArticleList.astro
Normal file
49
src/components/ArticleList.astro
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import { Image } from 'astro:assets';
|
||||
import { articlePath, formatDate } from '../lib/site';
|
||||
import TagList from './TagList.astro';
|
||||
|
||||
interface Props {
|
||||
posts: CollectionEntry<'posts'>[];
|
||||
showYear?: boolean;
|
||||
currentTag?: string;
|
||||
}
|
||||
|
||||
const { posts, showYear = false, currentTag } = Astro.props;
|
||||
---
|
||||
|
||||
<ol class="article-list">
|
||||
{
|
||||
posts.map((post) => {
|
||||
const href = articlePath(post);
|
||||
return (
|
||||
<li>
|
||||
<time datetime={post.data.date.toISOString()}>
|
||||
{showYear ? formatDate(post.data.date) : formatDate(post.data.date)}
|
||||
</time>
|
||||
<div>
|
||||
<a class="entry-title" href={href}>
|
||||
{post.data.title}
|
||||
</a>
|
||||
<p>{post.data.description}</p>
|
||||
<TagList tags={post.data.tags} currentTag={currentTag} />
|
||||
</div>
|
||||
<a
|
||||
class="entry-thumbnail article-thumbnail"
|
||||
href={href}
|
||||
aria-label={post.data.title}
|
||||
>
|
||||
<Image
|
||||
src={post.data.thumbnail.src}
|
||||
alt={post.data.thumbnail.alt}
|
||||
widths={[160, 240, 320, 480]}
|
||||
sizes="(max-width: 700px) 5rem, 10rem"
|
||||
loading="lazy"
|
||||
/>
|
||||
</a>
|
||||
</li>
|
||||
);
|
||||
})
|
||||
}
|
||||
</ol>
|
||||
Loading…
Add table
Add a link
Reference in a new issue