<template>
  <AppCard :title="$t('menu.story')" class="home-alumni" titleAlign="center">
    <template #title>
      <nuxt-link to="/alumnus/story">{{ $t('menu.story') }}</nuxt-link>
    </template>
    <template #header-aside>
      <nuxt-link to="/alumnus/story">{{ $t('viewMore') }}</nuxt-link>
    </template>
    <AppLink v-if="firstItem" :data="firstItem" :to="`/alumnus/story/${firstItem.id}`">
      <div class="alumni_content">
        <img class="content_img" :src="firstItem.web_img_uri" loading="lazy" />
        <div class="content_desc">
          <div class="desc_tit">{{ firstItem.title }}</div>
          <div class="desc_con">{{ firstItem.abstract }}</div>
        </div>
      </div>
    </AppLink>
  </AppCard>
</template>
<script setup>
import httpRequest from '@/utils/httpRequest'

const config = useRuntimeConfig()
const listData = ref([])
const firstItem = computed(() => listData.value[0])

const fetchList = async () => {
  const params = { project_id: config.public.projectId, type_tag: 'article_alumni' }
  const res = await httpRequest.get('/api/cms/api/v1/articles', { params })
  listData.value = res.data.data || []
}

onMounted(() => {
  fetchList()
})
</script>
<style lang="scss">
.alumni_content {
  display: flex;
  height: 450px;

  .content_img {
    width: 600px;
    height: 100%;
    object-fit: cover;
  }
  .content_desc {
    width: 568px;
    height: 100%;
    margin-left: 32px;
    .desc_tit {
      margin-top: 56px;
      font-size: 20px;
      line-height: 32px;
      color: #000000;
    }
    .desc_con {
      text-align: justify;
      font-size: 16px;
      font-weight: 400;
      line-height: 34px;
      color: #666666;
      margin-top: 30px;
    }
  }
}
</style>
