Details.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <LayoutContainer>
  3. <div class="news-section">
  4. <v-row class="mb-6 center-90">
  5. <v-col class="d-flex align-items-center">
  6. <v-btn
  7. to="/actualites"
  8. prepend-icon="fas fa-arrow-left"
  9. variant="outlined"
  10. class="back-button"
  11. >
  12. Retour aux actualités
  13. </v-btn>
  14. </v-col>
  15. </v-row>
  16. <div>
  17. <div v-if="pending">
  18. <v-row class="justify-center progress">
  19. <v-progress-circular
  20. indeterminate
  21. color="grey"
  22. />
  23. </v-row>
  24. </div>
  25. <div v-else-if="newsItem !== null" class="news">
  26. <CommonMeta
  27. :title="newsItem.title"
  28. :description="newsItem.leadText"
  29. />
  30. <v-row class="center-90 mb-12">
  31. <v-col cols="12" md="6">
  32. <v-img
  33. :src="getImageUrl(newsItem.attachment)"
  34. cover
  35. />
  36. </v-col>
  37. <v-col cols="12" md="6" class="d-flex flex-column justify-center">
  38. <h3>
  39. {{ newsItem.title }}
  40. </h3>
  41. <strong>
  42. {{ newsItem.leadText }}
  43. </strong>
  44. </v-col>
  45. </v-row>
  46. <v-row class="center-90">
  47. <p
  48. v-html="newsItem.bodyText"
  49. class="description"
  50. />
  51. </v-row>
  52. <v-row class="d-flex justify-center align-center">
  53. <v-btn
  54. v-if="newsItem.linkButton"
  55. :href="newsItem.linkButton"
  56. target="_blank"
  57. class="btn-plus mb-12"
  58. :text="true"
  59. >
  60. En savoir plus
  61. </v-btn>
  62. </v-row>
  63. <v-row class="d-flex justify-space-between center-90">
  64. <div>
  65. <p v-if="newsItem.tags.length > 0">
  66. MOTS CLÉS
  67. </p>
  68. </div>
  69. <div v-if="mdAndUp">
  70. <p>PARTAGER</p>
  71. </div>
  72. </v-row>
  73. <v-row class="d-flex justify-space-between mb-8 center-90">
  74. <p class="key-word mt-3">
  75. <span v-for="tag in newsItem.tags" class="mr-2">
  76. {{ tag.name }}
  77. </span>
  78. </p>
  79. <CommonShare v-if="mdAndUp" />
  80. </v-row>
  81. <div v-if="smAndDown" class="center-90">
  82. <p>PARTAGER</p>
  83. <CommonShare />
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </LayoutContainer>
  89. </template>
  90. <script setup lang="ts">
  91. import { useEntityFetch } from "~/composables/data/useEntityFetch";
  92. import News from "~/models/Maestro/News";
  93. import { useDisplay } from "vuetify";
  94. const { mdAndUp, smAndDown } = useDisplay()
  95. const route = useRoute();
  96. const { fetch } = useEntityFetch()
  97. const config = useRuntimeConfig()
  98. const newsId: number = parseInt(route.params.id as string)
  99. if (!newsId || isNaN(newsId)) {
  100. throw new Error('Missing or invalid id')
  101. }
  102. const { data: newsItem, pending } = fetch(News, newsId)
  103. const getImageUrl = (attachment: string): string | null => {
  104. if (!attachment) {
  105. return null
  106. }
  107. return `${config.public.apiBaseUrl}/uploads/news/${attachment}`
  108. }
  109. </script>
  110. <style scoped>
  111. .news {
  112. .v-img {
  113. max-height: 600px;
  114. margin-left: auto;
  115. margin-right: auto;
  116. }
  117. h3 {
  118. text-decoration: none;
  119. text-transform: uppercase;
  120. font-size: 36px;
  121. font-weight: 600;
  122. color: var(--primary-color);
  123. }
  124. strong {
  125. font-size: 21px;
  126. margin-top: 16px;
  127. }
  128. .description {
  129. color: var(--primary-color);
  130. max-width: 80%;
  131. font-size: 21px;
  132. font-weight: 500;
  133. line-height: 34px;
  134. margin-left: auto;
  135. margin-right: auto;
  136. margin-bottom: 3rem;
  137. }
  138. .btn-plus {
  139. background: var(--secondary-color);
  140. color: var(--on-secondary-color);
  141. display: flex;
  142. left: 0;
  143. padding: 25px 28px;
  144. align-items: center;
  145. gap: 9px;
  146. font-size: 0.9rem;
  147. border-radius: 5px;
  148. font-weight: 700;
  149. line-height: 15px;
  150. letter-spacing: 1.3px;
  151. text-transform: uppercase;
  152. margin-bottom: -1rem;
  153. }
  154. }
  155. .back-button {
  156. text-decoration: none;
  157. color: var(--on-neutral-color);
  158. font-size: 0.9rem;
  159. font-weight: 700;
  160. line-height: 15px;
  161. letter-spacing: 1.8px;
  162. text-transform: uppercase;
  163. }
  164. .key-word {
  165. color: var(--on-neutral-color);
  166. font-size: 20px;
  167. font-weight: 500;
  168. line-height: 24px;
  169. }
  170. </style>