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 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 { authPB } from "src/utils/pocketbase";
|
||||||
import { getFormattedDate } from '@utils/date'
|
|
||||||
|
|
||||||
export const prerender = false
|
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">
|
<div slot="sidebar" class="text-left">
|
||||||
A few thoughts I've had, whenever I feel like it as you can see!
|
A few thoughts I've had, whenever I feel like it as you can see!
|
||||||
|
|
||||||
<p class="text-xl mt-4">Tags</p>
|
<TagList tags={uniqueTags}/>
|
||||||
{
|
|
||||||
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>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div slot="content" class="py-12">
|
<div slot="content" class="py-12">
|
||||||
{
|
{ posts.map(p => <PostCard p={p}/>) }
|
||||||
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>
|
|
||||||
))
|
|
||||||
}
|
|
||||||
</div>
|
</div>
|
||||||
</Base>
|
</Base>
|
||||||
Reference in New Issue
Block a user