Index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. <div v-if="edge.node.espace" class="blank-page no-folio breakBeforeLeft" />
  69. <h2 :id="`chapitres${edge.node.id}`" class="section-title canbreak">{{edge.node.Titre}}</h2>
  70. <VueMarkdown class="chapter-content">{{edge.node.Contenu}}
  71. </VueMarkdown>
  72. </div>
  73. </Layout>
  74. </template>
  75. <script>
  76. const axios = require('axios'),
  77. path = require('path'),
  78. param = require(`../../param.JSON`);
  79. import {
  80. Previewer
  81. } from 'pagedjs'
  82. import VueMarkdown from 'vue-markdown'
  83. import Vue2Filters from 'vue2-filters'
  84. export default {
  85. mixins: [Vue2Filters.mixin],
  86. components: {
  87. VueMarkdown
  88. },
  89. mounted() {
  90. // Ajouter les citations
  91. let citations = Array.from(document.querySelectorAll("blockquote"));
  92. citations.forEach((c, index) => {
  93. c.id = `citation-${index}`;
  94. });
  95. // Ajouter les images
  96. let docImages = Array.from(
  97. document.querySelectorAll("img")
  98. )
  99. let toLoad = docImages.filter(img => img.alt === "insert");
  100. let imgSource;
  101. axios.get(path.join(param.source, "images")).then(r => {
  102. imgSource = r.data;
  103. let allPromises = [];
  104. toLoad.forEach(img => {
  105. let img_id = img.src.split("/").pop();
  106. let found = imgSource.find(element => element.id == img_id);
  107. img.src = path.join(param.source, found.images.url);
  108. img.id = `image-${img_id}`;
  109. img.parentNode.classList.add("breakBefore");
  110. let promise = new Promise((resolve, reject) => {
  111. img.onload = function() {
  112. let legend = document.createElement("p");
  113. legend.classList.add("breakAfter");
  114. legend.classList.add("legend");
  115. legend.innerHTML = found.legende;
  116. legend.id = `legend-${img_id}`;
  117. if (found.double) {
  118. let clone = img.parentNode.cloneNode(true);
  119. clone.classList.add("breakBefore");
  120. clone.querySelector("img").id += "-end";
  121. img.parentNode.insertBefore(clone, img.previousSibling);
  122. clone.parentNode.insertBefore(legend, clone.nextSibling);
  123. } else {
  124. img.parentNode.insertBefore(legend, img.nextSibling);
  125. }
  126. resolve();
  127. }
  128. });
  129. allPromises.push(promise);
  130. });
  131. Promise.all(allPromises).then(() => {
  132. let previewer = new Previewer();
  133. previewer.preview();
  134. });
  135. });
  136. }
  137. };
  138. </script>
  139. <page-query>
  140. query {
  141. sections: allSections {
  142. edges {
  143. node {
  144. id
  145. Titre
  146. Contenu
  147. Ordre
  148. espace
  149. }
  150. }
  151. }
  152. chapitres: allChapitres {
  153. edges {
  154. node {
  155. id
  156. Titre
  157. Contenu
  158. alternatif
  159. Rubrique
  160. }
  161. }
  162. }
  163. introductions: allIntroductions {
  164. edges {
  165. node {
  166. id
  167. contenu
  168. }
  169. }
  170. }
  171. }
  172. </page-query>
  173. <static-query>
  174. query {
  175. metadata {
  176. title
  177. subtitle
  178. authors
  179. }
  180. }
  181. </static-query>