index.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import Vue from 'vue'
  2. import Router from 'vue-router'
  3. import { REST } from 'api/rest-axios'
  4. import Home from 'pages/Home'
  5. // import Item from 'pages/Item'
  6. import ListCorpus from 'pages/ListCorpus'
  7. // import Corpus from 'pages/Corpus'
  8. import Edition from 'pages/Edition'
  9. import IndexNominum from 'pages/IndexNominum'
  10. import IndexLocorum from 'pages/IndexLocorum'
  11. import IndexOperum from 'pages/IndexOperum'
  12. import Nominum from 'pages/Nominum'
  13. import Locorum from 'pages/Locorum'
  14. import Operum from 'pages/Operum'
  15. import Bibliographie from 'pages/Bibliographie'
  16. import NotFound from 'pages/NotFound'
  17. import Static from 'pages/Static'
  18. Vue.use(Router)
  19. const routes = [
  20. {
  21. name: 'home',
  22. path: '/',
  23. component: Home
  24. },
  25. {
  26. name: 'credits',
  27. path: '/credits',
  28. component: Static
  29. },
  30. {
  31. name: 'guide',
  32. path: '/guide',
  33. component: Static
  34. },
  35. {
  36. name: 'schema',
  37. path: '/schema',
  38. component: Static
  39. },
  40. {
  41. name: 'api',
  42. path: '/api',
  43. component: Static
  44. },
  45. {
  46. name: 'listcorpus',
  47. path: '/corpus',
  48. component: ListCorpus
  49. },
  50. // {
  51. // name: 'corpus',
  52. // path: '/corpus/:id',
  53. // component: Corpus
  54. // },
  55. {
  56. name: 'edition',
  57. path: '/texts/:id',
  58. component: Edition
  59. },
  60. {
  61. name: 'editiontext',
  62. path: '/texts/:id/:textid',
  63. component: Edition
  64. },
  65. {
  66. name: 'editiontextextract',
  67. path: '/texts/:id/:textid/:ocid',
  68. component: Edition
  69. },
  70. {
  71. name: 'indexNominum',
  72. path: '/indexNominum',
  73. component: IndexNominum
  74. },
  75. {
  76. name: 'nominum',
  77. path: '/indexNominum/:id',
  78. component: Nominum
  79. },
  80. {
  81. name: 'indexLocorum',
  82. path: '/indexLocorum',
  83. component: IndexLocorum
  84. },
  85. {
  86. name: 'locorum',
  87. path: '/indexLocorum/:id',
  88. component: Locorum
  89. },
  90. {
  91. name: 'indexOperum',
  92. path: '/indexOperum',
  93. component: IndexOperum
  94. },
  95. {
  96. name: 'operum',
  97. path: '/indexOperum/:id',
  98. component: Operum
  99. },
  100. {
  101. path: '/bibliography',
  102. redirect: '/bibliography/expressions'
  103. },
  104. {
  105. name: 'bibliographie',
  106. path: '/bibliography/:type',
  107. component: Bibliographie,
  108. props: true
  109. },
  110. {
  111. name: 'bibliographieItem',
  112. path: '/bibliography/:type/:uuid',
  113. component: Bibliographie,
  114. props: true
  115. },
  116. // redirects /items/uuid to /texts/[edid]/[textid]
  117. {
  118. name: 'items',
  119. path: '/items/:uuid',
  120. beforeEnter: async (to, from, next) => {
  121. console.log('items before enter', from, to, next)
  122. let item = await REST.get(`${window.apipath}/items/` + to.params.uuid, {})
  123. .then(({ data }) => {
  124. // console.log('corpus getEditionsList REST: author, data', author, data)
  125. return data.content
  126. })
  127. .catch((error) => {
  128. console.warn('Issue with getEditionsList', error)
  129. // Promise.reject(error)
  130. })
  131. console.log('items : item', item)
  132. // item.textid = 'gdpSauval1724'
  133. // this named route does not replace the url
  134. // next({ name: 'editiontext', params: { id: item.textid, textid: item.uuid }, replace: true })
  135. next({ path: `/texts/${item.textId}/${item.uuid}`, replace: true })
  136. },
  137. component: { render: () => null }
  138. },
  139. {
  140. name: 'notfound',
  141. path: '/404',
  142. alias: '*',
  143. component: NotFound
  144. }
  145. ]
  146. export default new Router({
  147. mode: 'history',
  148. routes
  149. })