Amp.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="amp-page">
  3. <div class="amp-main">
  4. <h1 class="amp-title">{{ news.title }}</h1>
  5. <div class="amp-preview">{{ news.description }}</div>
  6. <div class="amp-image" v-if="news.image">
  7. <amp-img
  8. layout="fill"
  9. :alt="news.image ? news.image.title : ''"
  10. :src="news.image ? news.image.url : ''"
  11. ></amp-img>
  12. </div>
  13. <div class="amp-content" ref="content">
  14. <div v-html="ampContent"></div>
  15. </div>
  16. </div>
  17. <amp-iframe
  18. height="300"
  19. layout="fixed-height"
  20. sandbox="allow-scripts allow-same-origin allow-popups"
  21. frameborder="0"
  22. src="https://news.gnezdo.ru/amp_loader.html?tizerId=21507"
  23. ></amp-iframe>
  24. <amp-ad
  25. layout="fixed-height"
  26. height="250"
  27. type="luckyads"
  28. data-la-block="1ac9fe2c-26bd-406e-bf56-304a412aa85e"
  29. src="https://arhylm.com/6m17l1291vilp0my038qh867vqu768/kypag0x.php"
  30. ></amp-ad>
  31. <div class="amp-bottom">
  32. <nuxt-link :to="link" class="amp-link">Полная версия</nuxt-link>
  33. </div>
  34. <amp-analytics id="analytics1" type="googleanalytics">
  35. <script type="application/json" v-html="this.googleanalytics"></script>
  36. </amp-analytics>
  37. <amp-analytics type="metrika">
  38. <script type="application/json" v-html="this.metrika"></script>
  39. </amp-analytics>
  40. <amp-analytics config="https://top-fwz1.mail.ru/amp-analytics.config.json">
  41. <script type="application/json" v-html="this.mail"></script>
  42. </amp-analytics>
  43. </div>
  44. </template>
  45. <script>
  46. export default {
  47. amp: "only",
  48. ampLayout: "amp",
  49. data() {
  50. return {
  51. googleanalytics: `
  52. {
  53. "vars": {
  54. "account": "UA-21345164-1"
  55. },
  56. "triggers": {
  57. "trackPageview": {
  58. "on": "visible",
  59. "request": "pageview"
  60. }
  61. }
  62. }
  63. `,
  64. metrika: `
  65. {
  66. "vars": {
  67. "counterId": "34950850"
  68. },
  69. "triggers": {
  70. "halfScroll": {
  71. "on": "scroll",
  72. "scrollSpec": {
  73. "verticalBoundaries": [50]
  74. },
  75. "request": "reachGoal",
  76. "vars": {
  77. "goalId": "halfScrollGoal"
  78. }
  79. },
  80. "defaultPageview": {
  81. "on": "visible",
  82. "request": "pageview"
  83. }
  84. }
  85. }
  86. `,
  87. mail: `
  88. {
  89. "vars": {
  90. "id": "55851"
  91. }
  92. }
  93. `,
  94. };
  95. },
  96. props: {
  97. news: {
  98. type: Object,
  99. required: true,
  100. },
  101. },
  102. computed: {
  103. link() {
  104. const { category, alias } = this.$route.params;
  105. return {
  106. name: "news-category-alias",
  107. params: { category, alias },
  108. };
  109. },
  110. ampContent() {
  111. return this.news.content
  112. .replace(/<iframe([^>]*)><\/iframe>/gi, (match, sub) => {
  113. return `<amp-iframe class="amp-content-iframe" ${sub} height="9" width="16" layout="responsive"></amp-iframe>`;
  114. })
  115. .replace(/<img([^>]*)>/gi, (match, sub) => {
  116. return `<amp-img class="amp-content-image" ${sub} height="150" width="300" layout="responsive"></amp-img>`;
  117. });
  118. },
  119. }
  120. };
  121. </script>
  122. <style scoped>
  123. </style>