all posts page is pretty much just copy pasted from V2,,, idk if i wanna change that tbh it is quite good
This commit is contained in:
@@ -3,6 +3,8 @@ import Base from "src/layout/Base.astro"
|
||||
import Carousel from "@components/photos/carousel"
|
||||
import { authPB } from 'src/utils/pocketbase'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const pb = await authPB()
|
||||
const photos = await pb.collection('photos').getFullList({
|
||||
sort: '-created'
|
||||
|
||||
5
web/src/pages/posts/[slug].astro
Normal file
5
web/src/pages/posts/[slug].astro
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
import Base from "@layout/Base";
|
||||
|
||||
export const prerender = false
|
||||
---
|
||||
58
web/src/pages/posts/index.astro
Normal file
58
web/src/pages/posts/index.astro
Normal file
@@ -0,0 +1,58 @@
|
||||
---
|
||||
import Base from "src/layout/Base.astro";
|
||||
import { authPB } from "src/utils/pocketbase";
|
||||
import { getFormattedDate } from '@utils/date'
|
||||
|
||||
export const prerender = false
|
||||
|
||||
const pb = await authPB()
|
||||
|
||||
const posts = await pb.collection('posts').getFullList({
|
||||
sort: '-publishDate',
|
||||
filter: 'published=true'
|
||||
})
|
||||
|
||||
const tags = posts.flatMap(p => p.tags)
|
||||
const uniqueTags = tags.filter((v, i, a) => a.indexOf(v) === i)
|
||||
---
|
||||
|
||||
<Base>
|
||||
<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>
|
||||
)
|
||||
}
|
||||
</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>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</Base>
|
||||
4
web/src/pages/posts/tag/[tag].astro
Normal file
4
web/src/pages/posts/tag/[tag].astro
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
|
||||
export const prerender = false
|
||||
---
|
||||
11
web/src/utils/date.ts
Normal file
11
web/src/utils/date.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
export function getFormattedDate(date: string | number | Date) {
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat("en-GB", {
|
||||
day: "numeric",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
});
|
||||
|
||||
return dateFormat.format(new Date(date));
|
||||
}
|
||||
Reference in New Issue
Block a user