Index.vue 5.0 KB

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