<template>
  <div class="max-w-4xl mx-auto">
    <div class="mb-8">
      <h1 class="text-3xl font-bold mb-4">所有文章</h1>
      <div class="text-gray-600">记录学习与生活的点点滴滴</div>
    </div>
    
    <div class="grid gap-6">
      <ContentList path="/" :query="{ sort: [{ date: -1 }] }" v-slot="{ list }">
        <div v-for="article in list" :key="article._path" 
             class="bg-white rounded-lg shadow-sm p-6 hover:shadow-md transition-shadow">
          <NuxtLink :to="article._path" class="block group">
            <div class="flex justify-between items-start gap-4">
              <div>
                <h2 class="text-xl font-bold mb-2 group-hover:text-blue-600 transition-colors">
                  {{ article.title }}
                </h2>
                <p class="text-gray-600 mb-4 line-clamp-2">{{ article.description }}</p>
                <div class="flex items-center text-sm text-gray-500 gap-4">
                  <span>
                    {{ new Date(article.date).toLocaleDateString('zh-CN', { 
                      year: 'numeric',
                      month: 'long',
                      day: 'numeric'
                    }) }}
                  </span>
                  <span v-if="article.tags" class="flex gap-2">
                    <span v-for="tag in article.tags" :key="tag" 
                          class="px-2 py-1 bg-gray-100 rounded-full text-xs">
                      {{ tag }}
                    </span>
                  </span>
                </div>
              </div>
              <div v-if="article.cover" class="flex-shrink-0">
                <img :src="article.cover" :alt="article.title" 
                     class="w-32 h-24 object-cover rounded-lg" />
              </div>
            </div>
          </NuxtLink>
        </div>
      </ContentList>
    </div>
  </div>
</template>
