PronounsPage/app/components/blog/BlogEntriesList.vue
Valentyne Stigloher 10180aa6a3 (refactor) use #shared alias instead of ~~/shared
the #shared alias used by Nuxt cannot be easily disabled and to prevent breackage with jiti, we make use of it
2025-08-17 18:56:02 +02:00

56 lines
1.3 KiB
Vue

<script setup lang="ts">
import Columnist from 'avris-columnist';
import type { Post } from '#shared/blog/metadata.ts';
const props = withDefaults(defineProps<{
posts: string[] | Post[];
details?: boolean;
col?: number;
}>(), {
col: 4,
});
const config = useConfig();
const { data: postsFull } = useAsyncData(`posts-${JSON.stringify(props.posts)}`, async () => {
if (!props.posts.length) {
return [];
}
if (typeof props.posts[0] === 'object') {
return props.posts as Post[];
}
return await $fetch('/api/blog', {
query: {
locale: config.locale,
slugs: props.posts,
},
});
});
const entries = useTemplateRef<HTMLDivElement>('entries');
onMounted(async () => {
if (entries.value) {
const columnist = new Columnist(entries.value);
columnist.start();
}
});
</script>
<template>
<div ref="entries" class="columnist-wall row">
<div v-for="post in postsFull" :key="post.slug" :class="`columnist-column col-12 col-sm-6 col-md-${col} mb-3`">
<BlogEntry :post :details />
</div>
</div>
</template>
<style lang="scss" scoped>
.columnist-wall > .columnist-column {
transition: margin-top .2s ease-in-out;
}
.post-title {
text-wrap: balance;
}
</style>