<template>
  <section class="catalog section">
    <div class="catalog__wrapper section-wrapper">
      <div class="catalog__container">
        <CatalogMenu />
        <main class="catalog__main">
          <div class="catalog-main">
            <div class="catalog-main__wrapper">
              <div class="catalog-main__topic">
                <ul class="catalog-main__topic-list">
                  <li class="catalog-main__topic-item">
                    <a
                      class="catalog-main__topic-link"
                      href="javascript:void(0)"
                      >Статьи</a
                    >
                  </li>
                  <!-- <li class="catalog-main__topic-item">
                    <nuxt-link :to="{ name: 'news-category', params: { category: categoryNewsList.category ? categoryNewsList.category.alias : ''}}"
                      class="catalog-main__topic-link"
                      href="javascript:void(0)"
                      >{{ categoryNewsList.category ? categoryNewsList.category.name : "" }}</nuxt-link
                    >
                  </li> -->
                </ul>
              </div>
              <div class="catalog-main__header">
                <h1> {{ categoryNewsList.category ? categoryNewsList.category.name : "Новости" }} </h1>
                <!--<a
                  class="catalog-main__subscribe button button_grey-dark button_grey-dark-short"
                  ><span class="button__text">Подписаться</span></a
                >-->
              </div>
              <div class="catalog-main__list">
                <div class="catalog-list">
                  <CatalogList :categoryNewsList="categoryNewsList.news" :pages="categoryNewsList.total_pages"/>
                </div>
              </div>
            </div>
          </div>
        </main>
      </div>
    </div>
  </section>
</template>v

<script>
import { mapGetters } from "vuex";
export default {
  watchQuery: ['page'],
  computed: {
    ...mapGetters({
      newsItem : "modules/news/newsItem",
      categoryNewsList: "modules/news/categoryNewsList"
    })
  },
  props: {
      category: {
          type: Object
      }
  },
  head() {
    return {
      title: 'Амик - Статьи',
      meta: [
        {
          name: "description",
          content:
           this.categoryNewsList.category.meta.description,
        },
        {
          name: "keys",
          content:
            this.categoryNewsList.category.meta.key
        },
      ],
      link: [
        {rel: 'canonical', href: 'https://www.amic.ru/articles'}
      ]
    };
  },
  async fetch({ store, route }) {
      await store.dispatch("modules/news/setCategoryNewsList", {category: 'articles', page: route.query.page})

      await store.dispatch("modules/news/setCategoriesList");
  },
  async asyncData({store}) {

      await store.dispatch("modules/ads/getAds")
  }

};
</script>

<style>
</style>
