_alias.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <VideoArticle :videoItem="videoItem" :filteredVideos="filteredVideos" />
  3. </template>
  4. <script>
  5. import { mapGetters } from "vuex";
  6. export default {
  7. colorMode: "dark",
  8. async fetch({ store, route, error }) {
  9. await store.dispatch("modules/news/setNewsItem", route.params);
  10. await store.dispatch("modules/news/setCategoryNewsList", {
  11. category: route.params.category,
  12. page: 1
  13. });
  14. const newsItem = store.getters['modules/news/newsItem'];
  15. if(!newsItem){
  16. error({ statusCode: 404 })
  17. }
  18. },
  19. async asyncData({ req, route }) {
  20. const host = req ? req.headers.host : window.location.origin;
  21. const url = host + route.path;
  22. return { url };
  23. },
  24. computed: {
  25. ...mapGetters({
  26. videoItem: "modules/news/newsItem",
  27. videos: "modules/news/categoryNewsList"
  28. }),
  29. filteredVideos() {
  30. return this.videos.news
  31. .filter(video => video.id != this.videoItem.id)
  32. .slice(0, 3);
  33. },
  34. videoLink() {
  35. if (this.videoItem.video.match("(www.)?youtube|youtu.be")) {
  36. const youtubeId = this.videoItem.video
  37. .split(/v\/|v=|youtu\.be\//)[1]
  38. .split(/[?&]/)[0];
  39. return `https://www.youtube.com/embed/${youtubeId}`;
  40. }
  41. return this.videoItem.video;
  42. }
  43. },
  44. head() {
  45. return {
  46. title: this.videoItem.title,
  47. meta: [
  48. {
  49. name: "copyright",
  50. content: "ИА Амител",
  51. },
  52. {
  53. name: "publisher",
  54. content: "https://g.page/amitel?gm",
  55. },
  56. {
  57. name: "description",
  58. content: this.videoItem.description ? this.videoItem.description : '',
  59. },
  60. {
  61. name: "keys",
  62. content: this.videoItem.meta.key ? this.videoItem.meta.key : '',
  63. },
  64. {
  65. name: "author",
  66. content: this.videoItem.show_author ? this.videoItem.author ? this.videoItem.author.name : "ИА Амител" : "ИА Амител",
  67. },
  68. {
  69. name: "mediator_author",
  70. content: "ИА Амител",
  71. },
  72. {
  73. hid: "twitter:title",
  74. name: "twitter:title",
  75. content: this.videoItem.title
  76. },
  77. {
  78. hid: "twitter:description",
  79. name: "twitter:description",
  80. content: this.videoItem.description
  81. },
  82. {
  83. hid: "twitter:image",
  84. name: "twitter:image",
  85. content: this.videoItem.image ? this.videoItem.image.url : ""
  86. },
  87. {
  88. hid: "twitter:image:alt",
  89. name: "twitter:image:alt",
  90. content: this.videoItem.image ? this.videoItem.image.title : ""
  91. },
  92. {
  93. hid: "og:title",
  94. property: "og:title",
  95. content: this.videoItem.title
  96. },
  97. {
  98. hid: "og:description",
  99. property: "og:description",
  100. content: this.videoItem.description
  101. },
  102. {
  103. hid: "og:image",
  104. property: "og:image",
  105. content: this.videoItem.image ? this.videoItem.image.url : ""
  106. },
  107. {
  108. hid: "og:image:secure_url",
  109. property: "og:image:secure_url",
  110. content: this.videoItem.image ? this.videoItem.image.url : ""
  111. },
  112. {
  113. hid: "og:image:alt",
  114. property: "og:image:alt",
  115. content: this.videoItem.image ? this.videoItem.image.title : ""
  116. },
  117. {
  118. hid: "og:type",
  119. property: "og:type",
  120. content: "website"
  121. },
  122. {
  123. hid: "og:site_name",
  124. property: "og:site_name",
  125. content: "amic"
  126. },
  127. {
  128. hid: "og:url",
  129. property: "og:url",
  130. content: this.url
  131. },
  132. {
  133. hid: "fb:app_id",
  134. property: "fb:app_id",
  135. content: "4369125136471767"
  136. }
  137. ],
  138. link: [
  139. {rel: 'canonical', href: this.videoItem.category ? 'https://www.amic.ru/video/' + this.videoItem.category.alias + '/' + this.videoItem.alias : ''}
  140. ],
  141. };
  142. }
  143. };
  144. </script>
  145. <style lang="less" scoped></style>