routes.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import Home from '@/pages/Home'
  2. import TextOptions from '@/pages/_partials/TextOptions'
  3. export default [
  4. {
  5. name: 'home',
  6. path: '/',
  7. component: Home
  8. },
  9. {
  10. name: 'library',
  11. path: '/library',
  12. components: {
  13. default: () => import(/* webpackChunkName: "library" */ '@/pages/Library'),
  14. options: TextOptions
  15. },
  16. props: {
  17. default: ({ query }) => {
  18. let { mode = 'tree-map', texts = [] } = query
  19. if (typeof texts === 'string') texts = [texts]
  20. // In case of a reload or direct link, vue-router doesn't turn the query string into an array.
  21. if (texts && texts.length && typeof texts[0] === 'string') {
  22. texts = texts.map(text => text.split(',').map(id => parseInt(id)))
  23. }
  24. return { mode, texts }
  25. },
  26. options: ({ query }) => ({
  27. show: !('texts' in query && query.texts.length)
  28. })
  29. }
  30. },
  31. {
  32. name: 'kit',
  33. path: '/kit',
  34. component: () => import(/* webpackChunkName: "kit" */ '@/pages/Kit')
  35. },
  36. {
  37. name: 'gallery',
  38. path: '/gallery',
  39. component: () => import(/* webpackChunkName: "gallery" */ '@/pages/Gallery')
  40. },
  41. {
  42. name: 'blog',
  43. path: '/blog',
  44. component: () => import(/* webpackChunkName: "blog" */ '@/pages/Blog')
  45. },
  46. // TEMP
  47. {
  48. name: 'map',
  49. path: '/map',
  50. component: () => import(/* webpackChunkName: "blog" */ '@/pages/Map')
  51. },
  52. {
  53. name: 'notfound',
  54. path: '/404',
  55. alias: '*',
  56. component: () => import(/* webpackChunkName: "404" */ '@/pages/NotFound.vue')
  57. }
  58. ]