Index.vue 4.9 KB

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