more refactors
This commit is contained in:
18
web/src/components/postList/postCard.astro
Normal file
18
web/src/components/postList/postCard.astro
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
import { getFormattedDate } from "@utils/date"
|
||||
import { authPB } from "@utils/pocketbase"
|
||||
|
||||
const pb = await authPB()
|
||||
const { p } = Astro.props
|
||||
---
|
||||
|
||||
<div class="mb-5 w-2/3">
|
||||
<time datetime={p['publishDate']} class="min-w-[120px] text-gray-500">{getFormattedDate(p['publishDate'])}</time>
|
||||
<div>
|
||||
<a href={`/posts/${p['slug']}/`} rel="prefetch">
|
||||
<img src={ pb.files.getURL(p, p.headerImage) } class="rounded-xl border-12 border-white"/>
|
||||
{p['title']}
|
||||
</a>
|
||||
</div>
|
||||
<q class="line-clamp-3 block italic">{p['description']}</q>
|
||||
</div>
|
||||
21
web/src/components/postList/tagList.astro
Normal file
21
web/src/components/postList/tagList.astro
Normal file
@@ -0,0 +1,21 @@
|
||||
---
|
||||
const { tags } = Astro.props
|
||||
---
|
||||
|
||||
<p class="text-xl mt-4">Tags</p>
|
||||
{
|
||||
tags.length && (
|
||||
<ul class="flex flex-wrap gap-2">
|
||||
{tags.map(tag => (
|
||||
<li>
|
||||
<a
|
||||
href={`/posts/tag/${tag}/`}
|
||||
aria-label={`View all posts with the tag: ${tag}`}
|
||||
>
|
||||
#{tag}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
import Base from "src/layout/Base.astro";
|
||||
import TagList from "@components/postList/tagList";
|
||||
import PostCard from "@components/postList/postCard";
|
||||
import { authPB } from "src/utils/pocketbase";
|
||||
import { getFormattedDate } from '@utils/date'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
@@ -20,39 +21,10 @@ const uniqueTags = tags.filter((v, i, a) => a.indexOf(v) === i)
|
||||
<div slot="sidebar" class="text-left">
|
||||
A few thoughts I've had, whenever I feel like it as you can see!
|
||||
|
||||
<p class="text-xl mt-4">Tags</p>
|
||||
{
|
||||
uniqueTags.length && (
|
||||
<ul class="flex flex-wrap gap-2">
|
||||
{uniqueTags.map(tag => (
|
||||
<li>
|
||||
<a
|
||||
href={`/posts/tag/${tag}/`}
|
||||
aria-label={`View all posts with the tag: ${tag}`}
|
||||
>
|
||||
#{tag}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
<TagList tags={uniqueTags}/>
|
||||
</div>
|
||||
|
||||
<div slot="content" class="py-12">
|
||||
{
|
||||
posts.map(p => (
|
||||
<div class="mb-5 w-2/3">
|
||||
<time datetime={p['publishDate']} class="min-w-[120px] text-gray-500">{getFormattedDate(p['publishDate'])}</time>
|
||||
<div>
|
||||
<a href={`/posts/${p['slug']}/`} rel="prefetch">
|
||||
<img src={ pb.files.getURL(p, p.headerImage) } class="rounded-xl border-12 border-white"/>
|
||||
{p['title']}
|
||||
</a>
|
||||
</div>
|
||||
<q class="line-clamp-3 block italic">{p['description']}</q>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
{ posts.map(p => <PostCard p={p}/>) }
|
||||
</div>
|
||||
</Base>
|
||||
Reference in New Issue
Block a user