index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <section class="video section">
  3. <div class="video__wrapper section-wrapper podcasts-wrapper">
  4. <h1 class="podcast-h1">Слушай</h1>
  5. <template v-if="podcasts.length">
  6. <PodcastList
  7. v-if="podcasts.length > 0"
  8. v-for="podcast in podcasts"
  9. :podcast="podcast">
  10. </PodcastList>
  11. </template>
  12. </div>
  13. </section>
  14. </template>
  15. <script>
  16. import { mapGetters } from "vuex";
  17. export default {
  18. data: () => ({
  19. podcasts: [],
  20. }),
  21. computed: {
  22. ...mapGetters({
  23. allCategories: "modules/news/categoriesList",
  24. }),
  25. categories() {
  26. return this.allCategories.data.find((cat) => cat.alias === "slushay").child;
  27. },
  28. },
  29. props: {
  30. category: {
  31. type: Object
  32. }
  33. },
  34. methods: {
  35. loadPodcasts(category) {
  36. return this.$axios
  37. .get(`/news/category/${category.alias}`)
  38. .then((res) => res.data.data);
  39. },
  40. },
  41. async mounted() {
  42. const promises = this.categories.map(this.loadPodcasts);
  43. this.podcasts = await Promise.all(promises);
  44. console.log(this.podcasts.length);
  45. },
  46. head() {
  47. return {
  48. title: 'Амик - Подкасты',
  49. meta: [
  50. {
  51. name: "description",
  52. content: "",
  53. },
  54. {
  55. name: "keys",
  56. content: "",
  57. },
  58. ],
  59. link: [
  60. {rel: 'canonical', href: 'https://www.amic.ru/podcasts'}
  61. ]
  62. };
  63. },
  64. async asyncData({store}) {
  65. await store.dispatch("modules/ads/getAds");
  66. await store.dispatch("modules/news/setCategoriesList");
  67. }
  68. };
  69. </script>
  70. <style>
  71. .podcast-h1{
  72. margin-bottom: 30px;
  73. }
  74. </style>