<template>
  <Block
    :title="$_tr('title')"
    :link="{
      name: 'ClubsNewsListingPage',
      params: { slug: $route.params.slug }
    }"
    :link-label="$_tr('more')"
    title-tag="h3"
  >
    <component-listing
      id="club-news-listing"
      direction="vertical"
      endpoint="content/clubs_news"
      :pagination="false"
      :filters="filters"
    >
      <template #default="{ item }">
        <ResumeNews
          v-bind="item"
          :key="item.uuid"
          :to="{
            name: 'ClubsNewsPage',
            params: { slug: item.slug[0], clubs_slug: $route.params.slug }
          }"
          :categories-config="categoriesConfig"
        />
      </template>
    </component-listing>
  </Block>
</template>

<script>
import Block from '@inside-library/components/commons/components/lib/Block'

import ResumeNews from '@inside-news/components/lib/Resume'

export default {
  name: 'ClubsNews',
  $_i18nRootPath: 'customs.CLUBS_PAGE.NEWS',
  components: { Block, ResumeNews },
  data() {
    return {
      filters: {
        'status:eq': 1,
        sort: 'published_at:desc',
        clubs: { 'slug:eq': this.$route.params.slug },
        limit: 3
      },
      categoriesConfig: {
        news_categories: {
          data: (data, contentType, { getData }) => getData(data, contentType),
          disabledOn: ['ClubsNewsListingPage', 'ClubsPage']
        }
      }
    }
  }
}
</script>
