Index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <Layout>
  3. <div class="blank-page no-folio">
  4. <!-- Page blanche -->
  5. </div>
  6. <div class="v-center grow no-folio">
  7. <h1 class="pre-title center" v-html="$static.metaData.titreDuProjet" />
  8. <h2 class="pre-sub-title center" v-html="$static.metaData.sousTitre" />
  9. </div>
  10. <div class="blank-page no-folio">
  11. </div>
  12. <div class="column no-folio">
  13. <div class="bold center" v-for="auteur in $static.metaData.auteurs">
  14. {{auteur}}
  15. </div>
  16. <div class="v-center grow">
  17. <h1 class="main-title center" v-html="$static.metaData.titreDuProjet" />
  18. <h2 class="main-pre-title center" v-html="$static.metaData.sousTitre" />
  19. </div>
  20. <div class="center">
  21. Logo popsu
  22. </div>
  23. </div>
  24. <div class="column image-cover" v-bind:style='{ backgroundImage: "url(https://popsu.strapi.figli.io/" + $page.fonds.edges[1].node.url + ")", }'>
  25. <!-- Page fond 1 -->
  26. </div>
  27. <!-- Sommaire -->
  28. <div class="column column">
  29. <div class="column justify-end table-of-content">
  30. <span v-for="edge in $page.chapters.edges.slice().reverse()" :key="'content'+edge.node.id">
  31. <a :href="'#chapter'+edge.node.id">{{ edge.node.titre }}</a>
  32. </span>
  33. </div>
  34. </div>
  35. <div class="blank-page no-folio">
  36. <!-- Page blanche -->
  37. </div>
  38. <div class="hyphen" v-for="(edge,index) in $page.chapters.edges.slice().reverse()" :key="'chapter'+edge.node.id">
  39. <h2 v-bind:id="'chapter'+edge.node.id" class="chapter-title" v-bind:class="{ canbreak: isNotFirst(index) }" >{{ edge.node.titre }}</h2>
  40. <p lang="fr" class="chapter-content" v-html="edge.node.contenu" />
  41. </div>
  42. <div class="blank-page no-folio">
  43. <!-- Page blanche -->
  44. </div>
  45. <!-- Pleine pages avant les sections -->
  46. <div class="column image-cover cover-left green" v-bind:style='{ backgroundImage: "url(https://popsu.strapi.figli.io/" + $page.fonds.edges[0].node.url + ")", }'>
  47. <!-- Page fond 2 -->
  48. </div>
  49. <div class="column image-cover cover-right green" v-bind:style='{ backgroundImage: "url(https://popsu.strapi.figli.io/" + $page.fonds.edges[0].node.url + ")", }'>
  50. <!-- Page fond 2 -->
  51. </div>
  52. <div class="blank-page no-folio">
  53. <!-- Page blanche -->
  54. </div>
  55. <div v-for="(edge,index) in $page.sections.edges.slice().reverse()" :key="'section'+edge.node.id">
  56. <h3 class="section-title" v-bind:class="{ canbreak: isNotFirst(index) }">{{ edge.node.titre }}</h3>
  57. <p lang="fr" class="section-content">{{ edge.node.contenu }}</p>
  58. </div>
  59. </Layout>
  60. </template>
  61. <page-query>
  62. {
  63. chapters : allchapitres{
  64. edges{node{id,titre,contenu}}
  65. }
  66. sections : allsections{
  67. edges{node{id,titre,contenu}}
  68. }
  69. fonds : allfonds{
  70. edges{node{id,url}}
  71. }
  72. }
  73. </page-query>
  74. <static-query>
  75. query {
  76. metaData {
  77. titreDuProjet
  78. sousTitre
  79. auteurs
  80. }
  81. }
  82. </static-query>
  83. <script>
  84. import VueMarkdown from 'vue-markdown'
  85. import {
  86. Previewer
  87. } from 'pagedjs';
  88. import css from '~/css/print.css'
  89. export default {
  90. components: {
  91. VueMarkdown
  92. },
  93. metaInfo: {
  94. title: 'HTML2print',
  95. },
  96. methods:{
  97. isNotFirst: function(index){
  98. if(index != 0) return true;
  99. return false;
  100. }
  101. },
  102. mounted() {
  103. this.$nextTick(function () {
  104. let hyphenopoly = document.createElement('script'),
  105. hyph = document.createElement('script');
  106. hyphenopoly.setAttribute('src', 'lib/Hyphenopoly-master/Hyphenopoly_Loader.js')
  107. hyph.setAttribute('src', 'lib/hyph.js')
  108. document.head.appendChild(hyph)
  109. document.head.appendChild(hyphenopoly)
  110. // HELP !
  111. // https://github.com/mnater/Hyphenopoly/blob/master/docs/Events.md#teardown-event
  112. // L'event fonctionne, mais ça rend une page vierge ᕦ(ò_óˇ)ᕤ
  113. setTimeout(()=>{
  114. let previewer = new Previewer();
  115. previewer.preview()
  116. },1000)
  117. })
  118. }
  119. }
  120. </script>
  121. <style>
  122. @media screen {
  123. body {
  124. background-color: whitesmoke;
  125. display:flex;
  126. flex-direction:column;
  127. align-items:center;
  128. }
  129. .pagedjs_pages{
  130. display:grid;
  131. grid-row-gap:1cm;
  132. grid-template-columns: 1fr 1fr;
  133. }
  134. .pagedjs_page:first-child{
  135. grid-column:2;
  136. }
  137. .pagedjs_page {
  138. background-color: #fdfdfd;
  139. flex: none;
  140. box-shadow: 0 0 1px rgba(0,0,0,0.2);
  141. }
  142. }
  143. </style>