add: category, date sorting

Add category layouts and date sorting
This commit is contained in:
webfussel 2025-06-12 09:08:21 +02:00
parent 91b59e4ebe
commit 9b66a79a8c
17 changed files with 2495 additions and 17729 deletions

View file

@ -1,25 +1,33 @@
<template>
<section id="blog" class="Blog content">
<div class="grid">
<BlogCard v-for="article in articles" v-bind="makeBlogCard(article)" />
<BlogCard v-for="article in articles" v-bind="makeBlogCard(article)"/>
</div>
</section>
</template>
<script setup lang="ts">
const { data } = await useAsyncData('articles', () => queryCollection('blog').limit(10).all())
import type { Category } from '../../components/Blog/types'
const { data } = await useAsyncData('articles', () => queryCollection('blog').order('date', 'DESC').limit(10).all())
const articles = data.value!
const makeBlogCard = (article : typeof articles[0]) => ({
const makeBlogCard = (article: typeof articles[0]) => ({
title: article.title,
description: article.description,
image: article.meta.image as string,
date: article.meta.date as string,
date: article.date as string,
excerpt: article.excerpt,
link: article.path,
tags: article.meta.tags as string[],
category: article.meta.category as string,
category: article.meta.category as Category,
author: article.meta.author as { name: string, image: string },
})
useHead({
link: [
{ rel: 'alternate', type: 'application/rss+xml', href: '/blog/rss.xml', title: 'blogfussel' },
],
})
</script>