feat: add icons to posts and photos to featured posts

This commit is contained in:
2025-02-23 14:31:14 +01:00
parent 7e578c4149
commit d7d5084ca2
8 changed files with 33 additions and 15 deletions

View File

@@ -21,7 +21,13 @@ const { post } = Astro.props;
<a href={tp(`/${post.collection}/${post.id.split("/")[0]}`)}>
<h2
class="text-2xl flex gap-2 items-center line-clamp text-ellipsis overflow-hidden">
{post.data.icon && <img src={post.data.icon} class="h-6" />}
{
post.data.icon?.length > 3 ? (
<img src={post.data.icon} class="h-6" />
) : post.data.icon?.length ? (
<span>{post.data.icon}</span>
) : null
}
{post.data.title}
</h2>
<p class="text-ellipsis overflow-hidden line-clamp-2">

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
src/content/photos/madeira-2025/index.mdx (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -33,9 +33,21 @@ const posts = filterCollection(
await getCollection("blog"),
getLocale(Astro.url),
);
const photos = filterCollection(
await getCollection("photos"),
getLocale(Astro.url),
);
const list = [...posts, ...photos];
list.sort((a, b) => {
return a.data.date > b.data.date ? -1 : 1;
});
// .sort((a, b) => {
// return a.data.date.getDate() > b.data.date.getDate() ? 1 : -1;
// });
console.log(list.map((post) => [post.data.date, post.data.title]));
const featuredPost = posts.find((post) => post.data?.featured);
const otherPosts = posts.filter((post) => featuredPost !== post).slice(0, 3);
const featuredPost = list.find((post) => post.data?.featured);
const otherPosts = list.filter((post) => featuredPost !== post).slice(0, 3);
---
<Layout title="Max Richter">