Index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <Layout>
  3. <!-- Mise en page -->
  4. <!-- introductions -->
  5. <div class="v-center grow">
  6. <div v-for="edge in $page.introductions.edges.slice().reverse()" :key="`introductions${edge.node.id}`">
  7. <VueMarkdown class="intro">{{edge.node.contenu}}
  8. </VueMarkdown>
  9. </div>
  10. </div>
  11. <div class="blank-page no-folio fill-motif-cross-left" />
  12. <!-- Auteurs, titre, sous-titre -->
  13. <div class="column no-folio">
  14. <div class="fill-motif-cross-right layer-1">
  15. </div>
  16. <div class="column layer-2">
  17. <div class="bold center" v-for="auteur in $static.metadata.authors">
  18. {{auteur}}
  19. </div>
  20. <div class="v-center grow">
  21. <div class="center">
  22. <h1 class="main-title center highlight-white" v-html="$static.metadata.title" />
  23. </br>
  24. <h2 class="main-pre-title center highlight-white" v-html="$static.metadata.subtitle" />
  25. </div>
  26. </div>
  27. <div class="center">
  28. <img src="/logo_popsu.png" alt="" style="width:2cm;">
  29. </div>
  30. </div>
  31. </div>
  32. <!-- Page de fond -->
  33. <div class="column image-cover image-bleed" v-bind:style='{ backgroundImage: `url(https://popsu-rouen-en.strapi.figli.io/uploads/50424a6a43e44551a4faa699f8ef3caa.JPEG)`, }' />
  34. <!-- Sommaire -->
  35. <div class="column">
  36. <div class="section-title still">
  37. Sommaire
  38. </div>
  39. <div class="column justify-end table-of-content">
  40. <span v-for="edge in $page.chapitres.edges.slice().reverse()" :key="`sommaire${edge.node.id}`">
  41. <a v-if="edge.node.alternatif" v-html="edge.node.alternatif" :href="'#chapitres'+edge.node.id">
  42. </a>
  43. <a v-else :href="'#chapitres'+edge.node.id">
  44. {{ edge.node.Titre }}
  45. </a>
  46. </span>
  47. </div>
  48. </div>
  49. <!-- Chapitres -->
  50. <div v-for="(edge,index) in $page.chapitres.edges.slice().reverse()" :key="`chapitre${edge.node.id}`">
  51. <div class="blank-page no-folio breakBeforeLeft" />
  52. <div v-if="edge.node.Rubrique">
  53. <div class="section-title" >
  54. {{edge.node.Rubrique}}
  55. </div>
  56. <h2 :id="`chapitres${edge.node.id}`" class="chapter-title ">{{edge.node.Titre}}</h2>
  57. </div>
  58. <div v-else>
  59. <h2 :id="`chapitres${edge.node.id}`" class="chapter-title">{{edge.node.Titre}}</h2>
  60. </div>
  61. <VueMarkdown class="chapter-content justify">{{edge.node.Contenu}}
  62. </VueMarkdown>
  63. </div>
  64. <!-- Page blanche -->
  65. <div class="blank-page" />
  66. <!-- Sections -->
  67. <div v-for="edge in orderBy($page.sections.edges,'node.Ordre')">
  68. <h2 :id="`chapitres${edge.node.id}`" class="section-title canbreak">{{edge.node.Titre}}</h2>
  69. <VueMarkdown class="chapter-content">{{edge.node.Contenu}}
  70. </VueMarkdown>
  71. </div>
  72. </Layout>
  73. </template>
  74. <script>
  75. const axios = require('axios'),
  76. path = require('path'),
  77. param = require(`../../param.JSON`);
  78. import {
  79. Previewer
  80. } from 'pagedjs'
  81. import VueMarkdown from 'vue-markdown'
  82. import Vue2Filters from 'vue2-filters'
  83. export default {
  84. mixins: [Vue2Filters.mixin],
  85. components: {
  86. VueMarkdown
  87. },
  88. mounted() {
  89. // Ajouter les citations
  90. let citations = Array.from(document.querySelectorAll("blockquote"));
  91. citations.forEach((c, index) => {
  92. c.id = `citation-${index}`;
  93. });
  94. // Ajouter les images
  95. let docImages = Array.from(
  96. document.querySelectorAll("img")
  97. )
  98. let toLoad = docImages.filter(img => img.alt === "insert");
  99. let imgSource;
  100. axios.get(path.join(param.source, "images")).then(r => {
  101. imgSource = r.data;
  102. let allPromises = [];
  103. toLoad.forEach(img => {
  104. let img_id = img.src.split("/").pop();
  105. let found = imgSource.find(element => element.id == img_id);
  106. img.src = path.join(param.source, found.images.url);
  107. img.id = `image-${img_id}`;
  108. img.parentNode.classList.add("breakBefore");
  109. let promise = new Promise((resolve, reject) => {
  110. img.onload = function() {
  111. let legend = document.createElement("p");
  112. legend.classList.add("breakAfter");
  113. legend.classList.add("legend");
  114. legend.innerHTML = found.legende;
  115. legend.id = `legend-${img_id}`;
  116. if (found.double) {
  117. let clone = img.parentNode.cloneNode(true);
  118. clone.classList.add("breakBefore");
  119. clone.querySelector("img").id += "-end";
  120. img.parentNode.insertBefore(clone, img.previousSibling);
  121. clone.parentNode.insertBefore(legend, clone.nextSibling);
  122. } else {
  123. img.parentNode.insertBefore(legend, img.nextSibling);
  124. }
  125. resolve();
  126. }
  127. });
  128. allPromises.push(promise);
  129. });
  130. Promise.all(allPromises).then(() => {
  131. let previewer = new Previewer();
  132. previewer.preview();
  133. });
  134. });
  135. }
  136. };
  137. </script>
  138. <page-query>
  139. query {
  140. sections: allSections {
  141. edges {
  142. node {
  143. id
  144. Titre
  145. Contenu
  146. Ordre
  147. }
  148. }
  149. }
  150. chapitres: allChapitres {
  151. edges {
  152. node {
  153. id
  154. Titre
  155. Contenu
  156. alternatif
  157. Rubrique
  158. }
  159. }
  160. }
  161. introductions: allIntroductions {
  162. edges {
  163. node {
  164. id
  165. contenu
  166. }
  167. }
  168. }
  169. }
  170. </page-query>
  171. <static-query>
  172. query {
  173. metadata {
  174. title
  175. subtitle
  176. authors
  177. }
  178. }
  179. </static-query>