Details.vue 5.0 KB

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