<script setup lang="ts">
const { id: project } = useProject();

const { data: projects, status, error } = await useFetch('/api/project');
</script>

<template>
    <Head>
        <Title>Liste des projets</Title>
    </Head>
    <div class="site-body-center-column">
        <div class="projects-container">
            <div v-if="status === 'success'" class="project-list">
                <div v-for="p of projects" class="project-item">
                    <NuxtLink class="project-title" :to="{ path: `/explorer/${p.id}${p.home}`, force: true }">{{ p.name }}</NuxtLink>
                    <div class="project-user">Par {{ p.username }}</div>
                    <div class="project-pages">{{ p.pages }} pages</div>
                    <div class="project-summary">{{ p.summary ?? "Sans contenu" }}</div>
                </div>
            </div>
            <div v-else-if="status === 'pending'" class="loading"></div>
        </div>
    </div>
</template>