<template>
  <div class="news-item">
    <nuxt-link :to="`/alumnus/${item.id}`">
      <img :src="item.photo_uri" class="news-item-pic" v-if="item.photo_uri" />
      <div class="news-item-content">
        <div class="news-item-content__date">{{ formatDate(item.created_time) }}</div>
        <div class="news-item-content__title">{{ item.title }}</div>
        <div class="news-item-content__text" v-if="item.summary">{{ item.summary }}</div>
      </div>
    </nuxt-link>
  </div>
</template>

<script>
export default {
  props: { item: { type: Object } },
  methods: {
    formatDate(value) {
      const date = new Date(value.replace(/\-/g, '/'))
      return date.getFullYear() + '/' + date.getMonth() + 1 + '/' + date.getDate()
    }
  }
}
</script>

<style lang="scss">
.news-item {
  margin-bottom: 0.1rem;
  background-color: #fff;
}
.news-item-pic {
  display: block;
  width: 100%;
  // height: 2.99rem;
  object-fit: cover;
}
.news-item-content {
  padding: 0.18rem;
}
.news-item-content__date {
  font-size: 0.1rem;
  color: #aa1941;
  line-height: 0.16rem;
}
.news-item-content__title {
  margin-top: 0.1rem;
  font-size: 0.14rem;
  font-weight: 500;
  color: #333;
  line-height: 0.24rem;
}
.news-item-content__text {
  margin-top: 0.2rem;
  font-size: 0.1rem;
  line-height: 0.2rem;
}
</style>
