Index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 :href="'#chapitres'+edge.node.id">{{ edge.node.Titre }}</a>
  37. </span>
  38. </div>
  39. </div>
  40. <!-- Chapitres -->
  41. <div v-for="edge in $page.chapitres.edges.slice().reverse()" :key="`chapitre${edge.node.id}`">
  42. <h2 :id="`chapitres${edge.node.id}`" class="chapter-title canbreak">{{edge.node.Titre}}</h2>
  43. <VueMarkdown class="chapter-content justify">{{edge.node.Contenu}}
  44. </VueMarkdown>
  45. </div>
  46. <!-- Page blanche -->
  47. <div class="blank-page no-folio" />
  48. <!-- Sections -->
  49. <div v-for="edge in $page.sections.edges.slice().reverse()" :key="`section${edge.node.Ordre}`">
  50. <h2 :id="`chapitres${edge.node.id}`" class="section-title canbreak">{{edge.node.Titre}}</h2>
  51. <VueMarkdown class="chapter-content justify">{{edge.node.Contenu}}
  52. </VueMarkdown>
  53. </div>
  54. </Layout>
  55. </template>
  56. <script>
  57. const axios = require('axios'),
  58. path = require('path'),
  59. param = require(`../../param.JSON`);
  60. import {
  61. Previewer
  62. } from 'pagedjs'
  63. import VueMarkdown from 'vue-markdown'
  64. export default {
  65. components: {
  66. VueMarkdown
  67. },
  68. mounted() {
  69. // Ajouter
  70. let citations = Array.from(document.querySelectorAll("blockquote"));
  71. citations.forEach((c,index)=>{
  72. c.id = `citation-${index}`;
  73. });
  74. // Ajouter les images
  75. let docImages = Array.from(
  76. document.querySelectorAll("img")
  77. )
  78. let toLoad = docImages.filter(img => img.alt === "insert");
  79. let imgSource;
  80. axios.get(path.join(param.source, "images")).then(r => {
  81. imgSource = r.data;
  82. let allPromises = [];
  83. toLoad.forEach(img => {
  84. let img_id = img.src.split("/").pop();
  85. let found = imgSource.find(element => element.id == img_id);
  86. img.src = path.join(param.source, found.images.url);
  87. img.id = `${image}-${img_id}`;
  88. let promise = new Promise((resolve, reject) => {
  89. img.onload = function() {
  90. let legend = document.createElement("p");
  91. legend.classList.add("breakAfter");
  92. legend.classList.add("legend");
  93. legend.innerHTML = found.legende;
  94. img.parentNode.insertBefore(legend, img.nextSibling);
  95. resolve();
  96. }
  97. });
  98. allPromises.push(promise);
  99. });
  100. Promise.all(allPromises).then(() => {
  101. let previewer = new Previewer();
  102. previewer.preview();
  103. });
  104. });
  105. }
  106. }
  107. </script>
  108. <page-query>
  109. query {
  110. sections: allSections {
  111. edges {
  112. node {
  113. id
  114. Titre
  115. Contenu
  116. Ordre
  117. }
  118. }
  119. }
  120. chapitres: allChapitres {
  121. edges {
  122. node {
  123. id
  124. Titre
  125. Contenu
  126. }
  127. }
  128. }
  129. introductions: allIntroductions {
  130. edges {
  131. node {
  132. id
  133. contenu
  134. }
  135. }
  136. }
  137. }
  138. </page-query>
  139. <static-query>
  140. query {
  141. metadata {
  142. title
  143. subtitle
  144. authors
  145. }
  146. }
  147. </static-query>