<template>
  <div class="links-page">
    <div class="container">
      <div class="row">
        <div class="col-12">
          <LineTxt label="پیوند ها"/>
        </div>
        <div class="col-12 col-md-6 links-view" v-for="item in links" :key="item._id">
          <a :href="item.url" target="_blank" class="links-item">
            <i class="far fa-check-square"></i>
            <span>{{ item.title }}</span>
          </a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>

export default {
  data() {
    return {
      links: null
    }
  },
  computed: {
    currentPortal() {
      return this.$route.params.portal
    },
  },
  async asyncData({$axios, error, params}) {
    const portalQuery = params.portal
    try {
      const links = await $axios.get(`/api/public/getLinks?portal=${portalQuery}`)
      return {
        links: links.data
      }
    } catch (e) {
      error({status: 500, message: "مشکلی پیش آمده است!"})

    }
  }
}

</script>
