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:
2025-11-14 17:14:03 +13:00
parent c37a78e409
commit 691c75db00
6 changed files with 82 additions and 1 deletions

View File

@@ -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'

View File

@@ -0,0 +1,5 @@
---
import Base from "@layout/Base";
export const prerender = false
---

View 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>

View File

@@ -0,0 +1,4 @@
---
export const prerender = false
---

11
web/src/utils/date.ts Normal file
View 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));
}

View File

@@ -6,8 +6,9 @@
"baseUrl": ".",
"paths": {
"@components/*": ["src/components/*.astro"],
"@layouts/*": ["src/layouts/*.astro"],
"@layout/*": ["src/layout/*.astro"],
"@styles/*": ["src/styles/*.css"],
"@utils/*": ["src/utils/*.ts"]
}
}
}