Details.vue 4.3 KB

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