Index.vue 5.0 KB

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