<template>
  <nuxt-link :to="{name: 'portal-news-details', params: {portal: $route.params.portal,details: item._id}}" v-slot="{href,navigate}" custom>
    <div @click="navigate" class="newsBox justifyBetween col-12 col-md-3 mb-4 pointer" :title="item.title">
      <div class="innerBox">
        <img :src="item.thumbCover" :alt="item.title">
        <div class="suTitrBox mt-1">
          <div>
            <h2>
<!--              <b>{{ item.summaryTitle }}</b>-->
              <span> {{ item.title }} </span>
            </h2>
          </div>
          <!--          <div>-->
          <!--            <h2>{{ item.title }}</h2>-->
          <!--          </div>-->
        </div>
        <h3 class="mt-2">{{ item.leadTitle || item.title }}</h3>
        <div class="row date">
          <div class="col-12">
            <p>{{ jDate(item.customDate) }}</p>
          </div>
          <div class="col-12">
            <a :href="href" class="btn btn-primary mt-2">
              <span class="txtBtn">ادامه مطلب</span>
            </a>
          </div>
        </div>
      </div>
    </div>
  </nuxt-link>
</template>

<script>
import moment from "moment-jalaali"

export default {
  props: {
    item: {
      required: true
    },
    timeIsAgo: {
      type: Boolean,
      default: true,
    }
  },
  methods: {
    jDate(data) {
      if (this.timeIsAgo) return moment(data).locale('fa').fromNow()
      else return moment(data).locale('fa').format('LL')
    }
  },
}
</script>
