NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

sidebar.vue 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template lang="pug">
  2. aside.sidebar
  3. section
  4. .shadow(v-if="type === 'artists' && layout !== 'single'")
  5. h1.t-up sort {{ type }} by
  6. ul
  7. li(v-for="option in sortOptions")
  8. router-link(:to="`/${type}/${sortTypes[option]}`").t-cap
  9. p {{ option }}
  10. .shadow(v-else)
  11. p {{ type }} sidebar
  12. .shadow(v-if="layout === 'single' && Object.keys(related).length" v-for="p2pPostType in Object.keys(related)")
  13. h3.t-up related {{ p2pPostType }}s
  14. ul
  15. li(v-for="relatedPost in related[p2pPostType]")
  16. router-link(v-if="relatedPost" :to="`/${relatedPost.type}s/${relatedPost.slug}`")
  17. p {{ relatedPost.title }}
  18. slot
  19. .shadow(v-if="layout === 'single'")
  20. exhibitions-sidebar
  21. .shadow(v-if="layout === 'single'")
  22. events-sidebar
  23. </template>
  24. <script>
  25. import exhibitionsSidebar from './exhibitions'
  26. import eventsSidebar from './events'
  27. import { sortTypes } from '@/utils/helpers'
  28. export default {
  29. props: {
  30. type: {
  31. type: String
  32. },
  33. layout: {
  34. type: String
  35. },
  36. related: {
  37. type: Object
  38. }
  39. },
  40. components: {
  41. exhibitionsSidebar,
  42. eventsSidebar,
  43. },
  44. data() {
  45. return {
  46. sortTypes: {
  47. 'most recent': `${sortTypes.recent}`,
  48. 'alphabetized': `${sortTypes.alpha}`,
  49. 'by material': `${sortTypes.material}`,
  50. 'by artist': `${sortTypes.artist}`,
  51. 'by episode': `${sortTypes.episode}`,
  52. }
  53. }
  54. },
  55. computed: {
  56. sortOptions() {
  57. let opts = []
  58. switch (this.type) {
  59. case 'artists':
  60. opts = [
  61. Object.keys(this.sortTypes)[0],
  62. Object.keys(this.sortTypes)[1],
  63. Object.keys(this.sortTypes)[2],
  64. ]
  65. break
  66. case 'shorts':
  67. opts = [
  68. Object.keys(this.sortTypes)[3],
  69. Object.keys(this.sortTypes)[2],
  70. ]
  71. break
  72. case 'guides':
  73. opts = [
  74. Object.keys(this.sortTypes)[0],
  75. Object.keys(this.sortTypes)[4],
  76. Object.keys(this.sortTypes)[2],
  77. ]
  78. break
  79. }
  80. return opts
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="postcss">
  86. aside.sidebar
  87. position: sticky
  88. top: 65px
  89. ul
  90. list-style: none
  91. </style>