Details.vue 4.8 KB

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