Basic post tagging system
Can get posts with some tags, but only using HTTP/S address. Fixed SinglePostCard URL to work from anywhere TODO: Add intelligent post filter TODO: 404 Page
This commit is contained in:
9
src/components/PostsList.astro
Normal file
9
src/components/PostsList.astro
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
import SinglePostCard from "./SinglePostCard.astro";
|
||||
|
||||
const { filteredPosts } = Astro.props;
|
||||
---
|
||||
|
||||
<div class="grid gap-2 lg:grid-cols-2">
|
||||
{filteredPosts.map((post) => <SinglePostCard post={post} />)}
|
||||
</div>
|
38
src/components/SinglePostCard.astro
Normal file
38
src/components/SinglePostCard.astro
Normal file
@ -0,0 +1,38 @@
|
||||
---
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from "./ui/card";
|
||||
|
||||
const { post, lang } = Astro.props;
|
||||
// Astro.url.toString().split("/").slice(0,-2).concat(post.slug).join("/").split("/").slice(0,-1).join("/")
|
||||
---
|
||||
|
||||
<div>
|
||||
<a href={`${Astro.url.origin}/${lang ? lang : "en"}/blog/${post.blog_slug}`}>
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<img
|
||||
src={post.data.image.url}
|
||||
alt={post.data.image.alt}
|
||||
class="rounded-md"
|
||||
/>
|
||||
<span class="py-2"></span>
|
||||
<CardTitle>{post.data.title}</CardTitle>
|
||||
<CardDescription>
|
||||
<p>
|
||||
{post.data.author} • {
|
||||
post.data.publishDate.toLocaleString(Astro.currentLocale)
|
||||
}
|
||||
</p>
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p>{post.data.description}</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</a>
|
||||
</div>
|
Reference in New Issue
Block a user