Index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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.id}`">
  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. let docImages = Array.from(
  70. document.querySelectorAll("img")
  71. )
  72. let toLoad = docImages.filter(img => img.alt === "insert");
  73. let imgSource;
  74. axios.get(path.join(param.source, "images")).then(r => {
  75. imgSource = r.data;
  76. let allPromises = [];
  77. toLoad.forEach(img => {
  78. let img_id = img.src.split("/").pop();
  79. let found = imgSource.find(element => element.id == img_id);
  80. img.src = path.join(param.source, found.images.url);
  81. let promise = new Promise((resolve, reject) => {
  82. img.onload = function() {
  83. let legend = document.createElement("p");
  84. legend.classList.add("breakAfter");
  85. legend.classList.add("legend");
  86. img.parentNode.classList.add("breakBefore");
  87. legend.innerHTML = found.legende;
  88. img.parentNode.insertBefore(legend, img.nextSibling);
  89. resolve();
  90. }
  91. });
  92. allPromises.push(promise);
  93. });
  94. Promise.all(allPromises).then(() => {
  95. let previewer = new Previewer();
  96. previewer.preview();
  97. });
  98. });
  99. }
  100. }
  101. </script>
  102. <page-query>
  103. query {
  104. sections: allSections {
  105. edges {
  106. node {
  107. id
  108. Titre
  109. Contenu
  110. }
  111. }
  112. }
  113. chapitres: allChapitres {
  114. edges {
  115. node {
  116. id
  117. Titre
  118. Contenu
  119. }
  120. }
  121. }
  122. introductions: allIntroductions {
  123. edges {
  124. node {
  125. id
  126. contenu
  127. }
  128. }
  129. }
  130. }
  131. </page-query>
  132. <static-query>
  133. query {
  134. metadata {
  135. title
  136. subtitle
  137. authors
  138. }
  139. }
  140. </static-query>