NEXT craftinamerica.org. Base setup for headless wordpress https://www.craftinamerica.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // SHAMELESS THEFT: https://github.com/EvanAgee/vuejs-wordpress-theme-starter
  2. import Vuex from 'vuex'
  3. import * as actions from './actions'
  4. import * as getters from './getters'
  5. import page from './modules/page'
  6. import post from './modules/post'
  7. import artist from './modules/artist'
  8. import episode from './modules/episode'
  9. import event from './modules/event'
  10. import exhibition from './modules/exhibition'
  11. import short from './modules/short'
  12. import technique from './modules/technique'
  13. import guide from './modules/guide'
  14. import object from './modules/object'
  15. import publication from './modules/publication'
  16. import sticky from './modules/sticky'
  17. const debug = process.env.NODE_ENV !== 'production'
  18. // Vue.config.devtools = true
  19. // Current page state
  20. const state = {
  21. title: wp.site_name,
  22. loading: true,
  23. hero: {
  24. url: null,
  25. type: null,
  26. text: 'sample hero text', // Does this ever display?
  27. playbutton: true,
  28. },
  29. currentGallery: null,
  30. view: 'list',
  31. randomPostsLoaded: false,
  32. randomPosts: []
  33. }
  34. const mutations = {
  35. SET_HERO(state, hero) {
  36. if (!hero.url) {
  37. console.warn('No hero url to set')
  38. state.hero.url = null
  39. state.hero.type = null
  40. state.hero.text = ''
  41. state.hero.playbutton = false
  42. } else {
  43. // console.warn('Setting hero', hero)
  44. state.hero.text = hero.text
  45. state.hero.url = hero.url
  46. state.hero.type = hero.heroType
  47. state.hero.playbutton = hero.heroType === 'video' ? true : false
  48. }
  49. state.loading = false
  50. },
  51. CLEAR_HERO(state) {
  52. state.loading = true
  53. state.hero = {
  54. url: null,
  55. type: null,
  56. text: '',
  57. playbutton: false,
  58. }
  59. },
  60. SET_GALLERY(state, idList) {
  61. state.gallery = idList
  62. },
  63. CLEAR_GALLERY(state) {
  64. state.gallery = null
  65. },
  66. STORE_FETCHED_RANDOM(state, { randomPosts }) {
  67. state.randomPosts = randomPosts
  68. },
  69. CLEAR_RANDOM(state) {
  70. state.randomPosts = []
  71. },
  72. RANDOM_LOADED(state, val) {
  73. state.randomPostsLoaded = val
  74. },
  75. }
  76. const store = new Vuex.Store({
  77. actions,
  78. getters,
  79. mutations,
  80. state,
  81. modules: {
  82. post,
  83. page,
  84. artist,
  85. episode,
  86. event,
  87. exhibition,
  88. short,
  89. technique,
  90. guide,
  91. object,
  92. publication,
  93. sticky,
  94. },
  95. strict: debug,
  96. })
  97. export default store