Index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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="chapter-content justify">{{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()`, }' />
  29. <!-- Sommaire -->
  30. <div class="column no-folio">
  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. img.parentNode.classList.add("breakBefore");
  86. legend.innerHTML = found.legende;
  87. img.parentNode.insertBefore(legend, img.nextSibling);
  88. resolve();
  89. }
  90. });
  91. allPromises.push(promise);
  92. });
  93. Promise.all(allPromises).then(() => {
  94. let previewer = new Previewer();
  95. previewer.preview();
  96. });
  97. });
  98. }
  99. }
  100. </script>
  101. <page-query>
  102. query {
  103. sections: allSections {
  104. edges {
  105. node {
  106. id
  107. Titre
  108. Contenu
  109. }
  110. }
  111. }
  112. chapitres: allChapitres {
  113. edges {
  114. node {
  115. id
  116. Titre
  117. Contenu
  118. }
  119. }
  120. }
  121. introductions: allIntroductions {
  122. edges {
  123. node {
  124. id
  125. contenu
  126. }
  127. }
  128. }
  129. }
  130. </page-query>
  131. <static-query>
  132. query {
  133. metadata {
  134. title
  135. subtitle
  136. authors
  137. }
  138. }
  139. </static-query>