Browse Source

:recycle: depluralize api and frontend getters and routes

tags/0.9.0
j 4 years ago
parent
commit
c3f2e4dcd7

+ 28
- 28
plugins/cia-endpoints/cia-end-points.php View File

25
      * The standard wordpress post_types
25
      * The standard wordpress post_types
26
      */
26
      */
27
     $page_controller = new Make_Endpoint_For('page');
27
     $page_controller = new Make_Endpoint_For('page');
28
-    $page_controller->register_custom_route('pages');
28
+    $page_controller->register_custom_route('page');
29
 
29
 
30
     $media_controller = new Make_Endpoint_For('media');
30
     $media_controller = new Make_Endpoint_For('media');
31
     $media_controller->register_custom_route('media');
31
     $media_controller->register_custom_route('media');
32
 
32
 
33
     $post_controller = new Make_Endpoint_For('post');
33
     $post_controller = new Make_Endpoint_For('post');
34
-    $post_controller->register_custom_route('posts');
34
+    $post_controller->register_custom_route('post');
35
 
35
 
36
     /**
36
     /**
37
      * Craft in America custom post_types
37
      * Craft in America custom post_types
38
      */
38
      */
39
     $episode_controller = new Make_Endpoint_For('episode');
39
     $episode_controller = new Make_Endpoint_For('episode');
40
-    $episode_controller->register_custom_route('episodes');
40
+    $episode_controller->register_custom_route('episode');
41
 
41
 
42
     $artist_controller = new Make_Endpoint_For('artist');
42
     $artist_controller = new Make_Endpoint_For('artist');
43
-    $artist_controller->register_custom_route('artists');
43
+    $artist_controller->register_custom_route('artist');
44
 
44
 
45
     $event_controller = new Make_Endpoint_For('event');
45
     $event_controller = new Make_Endpoint_For('event');
46
-    $event_controller->register_custom_route('events');
46
+    $event_controller->register_custom_route('event');
47
 
47
 
48
     $exhibition_controller = new Make_Endpoint_For('exhibition');
48
     $exhibition_controller = new Make_Endpoint_For('exhibition');
49
-    $exhibition_controller->register_custom_route('exhibitions');
49
+    $exhibition_controller->register_custom_route('exhibition');
50
 
50
 
51
     $sticky_controller = new Make_Sticky_Endpoint();
51
     $sticky_controller = new Make_Sticky_Endpoint();
52
     $sticky_controller->register_custom_route('sticky');
52
     $sticky_controller->register_custom_route('sticky');
55
      * Craft in America custom sort_types
55
      * Craft in America custom sort_types
56
      */
56
      */
57
     $sort_controller = new Make_Sort_By('artist', 'by_alpha');
57
     $sort_controller = new Make_Sort_By('artist', 'by_alpha');
58
-    $sort_controller->register_custom_route('artists/by-alpha');
58
+    $sort_controller->register_custom_route('artist/by-alpha');
59
     $sort_controller = new Make_Sort_By('artist', 'by_material');
59
     $sort_controller = new Make_Sort_By('artist', 'by_material');
60
-    $sort_controller->register_custom_route('artists/by-material');
60
+    $sort_controller->register_custom_route('artist/by-material');
61
     $sort_controller = new Make_Sort_By('event', 'by_past');
61
     $sort_controller = new Make_Sort_By('event', 'by_past');
62
-    $sort_controller->register_custom_route('events/by-past');
62
+    $sort_controller->register_custom_route('event/by-past');
63
     $sort_controller = new Make_Sort_By('exhibition', 'by_past');
63
     $sort_controller = new Make_Sort_By('exhibition', 'by_past');
64
-    $sort_controller->register_custom_route('exhibitions/by-past');
64
+    $sort_controller->register_custom_route('exhibition/by-past');
65
     $sort_controller = new Make_Sort_By('event', 'by_current');
65
     $sort_controller = new Make_Sort_By('event', 'by_current');
66
-    $sort_controller->register_custom_route('events/by-current');
66
+    $sort_controller->register_custom_route('event/by-current');
67
     $sort_controller = new Make_Sort_By('exhibition', 'by_current');
67
     $sort_controller = new Make_Sort_By('exhibition', 'by_current');
68
-    $sort_controller->register_custom_route('exhibitions/by-current');
68
+    $sort_controller->register_custom_route('exhibition/by-current');
69
     $sort_controller = new Make_Sort_By('event', 'by_upcoming');
69
     $sort_controller = new Make_Sort_By('event', 'by_upcoming');
70
-    $sort_controller->register_custom_route('events/by-upcoming');
70
+    $sort_controller->register_custom_route('event/by-upcoming');
71
     $sort_controller = new Make_Sort_By('exhibition', 'by_upcoming');
71
     $sort_controller = new Make_Sort_By('exhibition', 'by_upcoming');
72
-    $sort_controller->register_custom_route('exhibitions/by-upcoming');
72
+    $sort_controller->register_custom_route('exhibition/by-upcoming');
73
     $sort_controller = new Make_Sort_By('event', 'by_current_and_upcoming');
73
     $sort_controller = new Make_Sort_By('event', 'by_current_and_upcoming');
74
-    $sort_controller->register_custom_route('events/by-current-and-upcoming');
74
+    $sort_controller->register_custom_route('event/by-current-and-upcoming');
75
     $sort_controller = new Make_Sort_By('exhibition', 'by_current_and_upcoming');
75
     $sort_controller = new Make_Sort_By('exhibition', 'by_current_and_upcoming');
76
-    $sort_controller->register_custom_route('exhibitions/by-current-and-upcoming');
76
+    $sort_controller->register_custom_route('exhibition/by-current-and-upcoming');
77
 });
77
 });
78
 
78
 
79
 /**
79
 /**
83
  */
83
  */
84
 add_filter('wp_rest_cache/allowed_endpoints', function () {
84
 add_filter('wp_rest_cache/allowed_endpoints', function () {
85
     // The standard wordpress post_types
85
     // The standard wordpress post_types
86
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('posts', $allowed_endpoints['craft/v2']) )
87
-        $allowed_endpoints['craft/v2'][] = 'posts';
88
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('pages', $allowed_endpoints['craft/v2']) )
89
-        $allowed_endpoints['craft/v2'][] = 'pages';
86
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('post', $allowed_endpoints['craft/v2']) )
87
+        $allowed_endpoints['craft/v2'][] = 'post';
88
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('page', $allowed_endpoints['craft/v2']) )
89
+        $allowed_endpoints['craft/v2'][] = 'page';
90
     if ( !isset($allowed_endpoints['craft/v2']) || !in_array('media', $allowed_endpoints['craft/v2']) )
90
     if ( !isset($allowed_endpoints['craft/v2']) || !in_array('media', $allowed_endpoints['craft/v2']) )
91
         $allowed_endpoints['craft/v2'][] = 'media';
91
         $allowed_endpoints['craft/v2'][] = 'media';
92
 
92
 
93
     // Craft in America custom post_types
93
     // Craft in America custom post_types
94
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('episodes', $allowed_endpoints['craft/v2']) )
95
-        $allowed_endpoints['craft/v2'][] = 'episodes';
96
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('events', $allowed_endpoints['craft/v2']) )
97
-        $allowed_endpoints['craft/v2'][] = 'events';
98
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('exhibitions', $allowed_endpoints['craft/v2']) )
99
-        $allowed_endpoints['craft/v2'][] = 'exhibitions';
100
-    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('artists', $allowed_endpoints['craft/v2']) )
101
-        $allowed_endpoints['craft/v2'][] = 'artists';
94
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('episode', $allowed_endpoints['craft/v2']) )
95
+        $allowed_endpoints['craft/v2'][] = 'episode';
96
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('event', $allowed_endpoints['craft/v2']) )
97
+        $allowed_endpoints['craft/v2'][] = 'event';
98
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('exhibition', $allowed_endpoints['craft/v2']) )
99
+        $allowed_endpoints['craft/v2'][] = 'exhibition';
100
+    if ( !isset($allowed_endpoints['craft/v2']) || !in_array('artist', $allowed_endpoints['craft/v2']) )
101
+        $allowed_endpoints['craft/v2'][] = 'artist';
102
 
102
 
103
     return $allowed_endpoints;
103
     return $allowed_endpoints;
104
 }, 10, 1);
104
 }, 10, 1);

+ 7
- 7
vue-theme/src/pages/list.vue View File

13
 
13
 
14
         .posts(v-if="posts && loaded" :class="{ 'is-grid': grid }")
14
         .posts(v-if="posts && loaded" :class="{ 'is-grid': grid }")
15
             section(v-for="(post, i) in posts" :key="post.slug").shadow.post
15
             section(v-for="(post, i) in posts" :key="post.slug").shadow.post
16
-                card(:content="post" :type="type" :wide="type == 'exhibitions' && i > 1 || type == 'events' && i > 1 ")
16
+                card(:content="post" :type="type" :wide="type == 'exhibition' && i > 1 || type == 'event' && i > 1 ")
17
 
17
 
18
         footer
18
         footer
19
             p {{ `${type} count: ${Object.values(posts).length}` }}
19
             p {{ `${type} count: ${Object.values(posts).length}` }}
47
             return typeFromRoute(this.$route)
47
             return typeFromRoute(this.$route)
48
         },
48
         },
49
         dispatchName() {
49
         dispatchName() {
50
-            let type = convertTitleCase(this.type)
50
+            let type = convertTitleCase(this.type) + 's'
51
             return this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
51
             return this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
52
         },
52
         },
53
         loaded() {
53
         loaded() {
54
-            let type = convertTitleCase(this.type)
54
+            let type = convertTitleCase(this.type) + 's'
55
             if (!type) return
55
             if (!type) return
56
             return this[`all${type}Loaded`]
56
             return this[`all${type}Loaded`]
57
         },
57
         },
58
         posts() {
58
         posts() {
59
-            let type = convertTitleCase(this.type)
59
+            let type = convertTitleCase(this.type) + 's'
60
             if (!type) return
60
             if (!type) return
61
             return this[`all${type}`]
61
             return this[`all${type}`]
62
         },
62
         },
71
                       .filter(p => p)
71
                       .filter(p => p)
72
                       .pop()
72
                       .pop()
73
 
73
 
74
-            // console.log('Gettings posts:', this.type)
74
+            console.log('Gettings posts:', this.type)
75
             // if (!Object.values(sortTypes).includes(sort)) {
75
             // if (!Object.values(sortTypes).includes(sort)) {
76
             //     console.log('Sort not found:', sort)
76
             //     console.log('Sort not found:', sort)
77
             //     sort = null
77
             //     sort = null
81
             if (this.type && this.dispatchName) {
81
             if (this.type && this.dispatchName) {
82
                 this.$store.dispatch(this.dispatchName, sort)
82
                 this.$store.dispatch(this.dispatchName, sort)
83
 
83
 
84
-                if (this.type == 'events') {
84
+                if (this.type == 'event') {
85
                     this.$store.dispatch(
85
                     this.$store.dispatch(
86
                         'getAllExhibitions',
86
                         'getAllExhibitions',
87
                         sortTypes.currentAndUpcoming,
87
                         sortTypes.currentAndUpcoming,
88
                     )
88
                     )
89
                 }
89
                 }
90
-                if (this.type == 'exhibitions') {
90
+                if (this.type == 'exhibition') {
91
                     this.$store.dispatch(
91
                     this.$store.dispatch(
92
                         'getAllEvents',
92
                         'getAllEvents',
93
                         sortTypes.currentAndUpcoming,
93
                         sortTypes.currentAndUpcoming,

+ 3
- 1
vue-theme/src/pages/mixin-post-types.js View File

1
 import { convertTitleCase, postTypes } from '@/utils/helpers'
1
 import { convertTitleCase, postTypes } from '@/utils/helpers'
2
+import { capitalize } from '@vue/shared'
2
 import { mapGetters, mapState } from 'vuex'
3
 import { mapGetters, mapState } from 'vuex'
3
 
4
 
4
 /**
5
 /**
8
  */
9
  */
9
 const getterHelper = {}
10
 const getterHelper = {}
10
 for (let type of postTypes) {
11
 for (let type of postTypes) {
11
-    const capitalized = convertTitleCase(type)
12
+    const capitalized = convertTitleCase(type) + 's'
13
+    console.log(capitalized)
12
     getterHelper[`all${capitalized}BySlug`] = `all${capitalized}BySlug`
14
     getterHelper[`all${capitalized}BySlug`] = `all${capitalized}BySlug`
13
     getterHelper[`all${capitalized}`] = `all${capitalized}`
15
     getterHelper[`all${capitalized}`] = `all${capitalized}`
14
     getterHelper[`all${capitalized}Loaded`] = `all${capitalized}Loaded`
16
     getterHelper[`all${capitalized}Loaded`] = `all${capitalized}Loaded`

+ 5
- 5
vue-theme/src/pages/single.vue View File

15
             //- p(v-if="post.type") type: {{ post.type }}
15
             //- p(v-if="post.type") type: {{ post.type }}
16
             //- p(v-if="post.subtypes") subtypes: {{ post.subtypes }}
16
             //- p(v-if="post.subtypes") subtypes: {{ post.subtypes }}
17
 
17
 
18
-            .date-info(v-if="['exhibitions', 'events'].includes(type)")
18
+            .date-info(v-if="['exhibition', 'event'].includes(type)")
19
                 p start: {{ dateFrom(post.start) }}
19
                 p start: {{ dateFrom(post.start) }}
20
                 p end: {{ dateFrom(post.end) }}
20
                 p end: {{ dateFrom(post.end) }}
21
 
21
 
23
         section.content(v-html="post.content")
23
         section.content(v-html="post.content")
24
 
24
 
25
         //- related artists section for episodes
25
         //- related artists section for episodes
26
-        section(v-if="type === 'episodes' && post" :post="post")
26
+        section(v-if="type === 'episode' && post" :post="post")
27
             h2.t-up featured in this episode
27
             h2.t-up featured in this episode
28
             ul
28
             ul
29
                 li.f-row.between(v-for="artist in p2pPostsByType['artist']")
29
                 li.f-row.between(v-for="artist in p2pPostsByType['artist']")
30
-                    card(:content="artist" type="artists" :wide="true" :hide-type="true")
30
+                    card(:content="artist" type="artist" :wide="true" :hide-type="true")
31
             
31
             
32
-        credits(v-if="type === 'episodes' && post" :post="post")
32
+        credits(v-if="type === 'episode' && post" :post="post")
33
 
33
 
34
         //- end of article icon     
34
         //- end of article icon     
35
         footer.f-col
35
         footer.f-col
196
              * which is derived from the route
196
              * which is derived from the route
197
              * !: posts watcher fires when this finishes
197
              * !: posts watcher fires when this finishes
198
              */
198
              */
199
-            let type = convertTitleCase(this.type)
199
+            let type = convertTitleCase(this.type) + 's'
200
 
200
 
201
             if (!this.$store.state[this.type]) return
201
             if (!this.$store.state[this.type]) return
202
 
202
 

+ 4
- 4
vue-theme/src/router/routes.js View File

9
     { path: '/', component: indexPage },
9
     { path: '/', component: indexPage },
10
     // List Pages
10
     // List Pages
11
     {
11
     {
12
-        path: '/episodes',
12
+        path: '/episode',
13
         component: listPage,
13
         component: listPage,
14
         props: { sidebar: false, grid: true, sortBy: null },
14
         props: { sidebar: false, grid: true, sortBy: null },
15
     },
15
     },
16
     {
16
     {
17
-        path: '/artists',
17
+        path: '/artist',
18
         component: listPage,
18
         component: listPage,
19
         props: { sidebar: true, grid: true, sortBy: null },
19
         props: { sidebar: true, grid: true, sortBy: null },
20
     },
20
     },
21
     // Sorted List Pages
21
     // Sorted List Pages
22
     {
22
     {
23
-        path: `/artists/${sortTypes.alpha}`,
23
+        path: `/artist/${sortTypes.alpha}`,
24
         component: listPage,
24
         component: listPage,
25
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.alpha}` },
25
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.alpha}` },
26
     },
26
     },
27
     {
27
     {
28
-        path: `/artists/${sortTypes.material}`,
28
+        path: `/artist/${sortTypes.material}`,
29
         component: listPage,
29
         component: listPage,
30
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.material}` },
30
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.material}` },
31
     },
31
     },

+ 2
- 2
vue-theme/src/store/modules/artist.js View File

20
     getAllArtists({ commit }, sortType) {
20
     getAllArtists({ commit }, sortType) {
21
         commit('CLEAR_ARTISTS')
21
         commit('CLEAR_ARTISTS')
22
         commit('ARTISTS_LOADED', false)
22
         commit('ARTISTS_LOADED', false)
23
-        return api.getByType('artists', sortType, artists => {
23
+        return api.getByType('artist', sortType, artists => {
24
             commit('STORE_FETCHED_ARTISTS', { artists })
24
             commit('STORE_FETCHED_ARTISTS', { artists })
25
             commit('ARTISTS_LOADED', true)
25
             commit('ARTISTS_LOADED', true)
26
         })
26
         })
28
     getSingleArtist({ commit }, id) {
28
     getSingleArtist({ commit }, id) {
29
         commit('CLEAR_SINGLE_ARTISTS')
29
         commit('CLEAR_SINGLE_ARTISTS')
30
         commit('ARTISTS_LOADED', false)
30
         commit('ARTISTS_LOADED', false)
31
-        api.getSingleType('artists', id, artist => {
31
+        api.getSingleType('artist', id, artist => {
32
             commit('STORE_FETCHED_SINGLE_ARTIST', artist)
32
             commit('STORE_FETCHED_SINGLE_ARTIST', artist)
33
             commit('ARTISTS_LOADED', true)
33
             commit('ARTISTS_LOADED', true)
34
         })
34
         })

+ 2
- 2
vue-theme/src/store/modules/episode.js View File

20
     getAllEpisodes({ commit }, sortType) {
20
     getAllEpisodes({ commit }, sortType) {
21
         commit('CLEAR_EPISODES')
21
         commit('CLEAR_EPISODES')
22
         commit('EPISODES_LOADED', false)
22
         commit('EPISODES_LOADED', false)
23
-        return api.getByType('episodes', sortType, episodes => {
23
+        return api.getByType('episode', sortType, episodes => {
24
             commit('STORE_FETCHED_EPISODES', { episodes })
24
             commit('STORE_FETCHED_EPISODES', { episodes })
25
             commit('EPISODES_LOADED', true)
25
             commit('EPISODES_LOADED', true)
26
         })
26
         })
29
         console.log('clearing single ep from getSingle')
29
         console.log('clearing single ep from getSingle')
30
         commit('CLEAR_SINGLE_EPISODES')
30
         commit('CLEAR_SINGLE_EPISODES')
31
         commit('EPISODES_LOADED', false)
31
         commit('EPISODES_LOADED', false)
32
-        api.getSingleType('episodes', id, episode => {
32
+        api.getSingleType('episode', id, episode => {
33
             commit('STORE_FETCHED_SINGLE_EPISODE', episode)
33
             commit('STORE_FETCHED_SINGLE_EPISODE', episode)
34
             commit('EPISODES_LOADED', true)
34
             commit('EPISODES_LOADED', true)
35
         })
35
         })

+ 2
- 2
vue-theme/src/store/modules/event.js View File

27
     getAllEvents({ commit }, sortType) {
27
     getAllEvents({ commit }, sortType) {
28
         commit('CLEAR_EVENTS')
28
         commit('CLEAR_EVENTS')
29
         commit('EVENTS_LOADED', false)
29
         commit('EVENTS_LOADED', false)
30
-        return api.getByType('events', sortType, events => {
30
+        return api.getByType('event', sortType, events => {
31
             commit('STORE_FETCHED_EVENTS', { events })
31
             commit('STORE_FETCHED_EVENTS', { events })
32
             commit('EVENTS_LOADED', true)
32
             commit('EVENTS_LOADED', true)
33
         })
33
         })
35
     getSingleEvent({ commit }, id) {
35
     getSingleEvent({ commit }, id) {
36
         commit('CLEAR_SINGLE_EVENTS')
36
         commit('CLEAR_SINGLE_EVENTS')
37
         commit('EVENTS_LOADED', false)
37
         commit('EVENTS_LOADED', false)
38
-        api.getSingleType('events', id, event => {
38
+        api.getSingleType('event', id, event => {
39
             commit('STORE_FETCHED_SINGLE_EVENT', event)
39
             commit('STORE_FETCHED_SINGLE_EVENT', event)
40
             commit('EVENTS_LOADED', true)
40
             commit('EVENTS_LOADED', true)
41
         })
41
         })

+ 2
- 2
vue-theme/src/store/modules/exhibition.js View File

29
     getAllExhibitions({ commit }, sortType) {
29
     getAllExhibitions({ commit }, sortType) {
30
         commit('CLEAR_EXHIBITIONS')
30
         commit('CLEAR_EXHIBITIONS')
31
         commit('EXHIBITIONS_LOADED', false)
31
         commit('EXHIBITIONS_LOADED', false)
32
-        return api.getByType('exhibitions', sortType, exhibitions => {
32
+        return api.getByType('exhibition', sortType, exhibitions => {
33
             commit('STORE_FETCHED_EXHIBITIONS', { exhibitions })
33
             commit('STORE_FETCHED_EXHIBITIONS', { exhibitions })
34
             commit('EXHIBITIONS_LOADED', true)
34
             commit('EXHIBITIONS_LOADED', true)
35
         })
35
         })
37
     getSingleExhibition({ commit }, id) {
37
     getSingleExhibition({ commit }, id) {
38
         commit('CLEAR_SINGLE_EXHIBITIONS')
38
         commit('CLEAR_SINGLE_EXHIBITIONS')
39
         commit('EXHIBITIONS_LOADED', false)
39
         commit('EXHIBITIONS_LOADED', false)
40
-        api.getSingleType('exhibitions', id, exhibition => {
40
+        api.getSingleType('exhibition', id, exhibition => {
41
             commit('STORE_FETCHED_SINGLE_EXHIBITION', exhibition)
41
             commit('STORE_FETCHED_SINGLE_EXHIBITION', exhibition)
42
             commit('EXHIBITIONS_LOADED', true)
42
             commit('EXHIBITIONS_LOADED', true)
43
         })
43
         })

+ 2
- 2
vue-theme/src/store/modules/page.js View File

17
 const actions = {
17
 const actions = {
18
     async getAllPages({ commit }, sortType) {
18
     async getAllPages({ commit }, sortType) {
19
         commit('PAGES_LOADED', false)
19
         commit('PAGES_LOADED', false)
20
-        return await api.getByType('pages', sortType, pages => {
20
+        return await api.getByType('page', sortType, pages => {
21
             commit('STORE_FETCHED_PAGES', { pages })
21
             commit('STORE_FETCHED_PAGES', { pages })
22
             commit('PAGES_LOADED', true)
22
             commit('PAGES_LOADED', true)
23
         })
23
         })
25
     getSinglePage({ commit }, id) {
25
     getSinglePage({ commit }, id) {
26
         commit('CLEAR_SINGLE_PAGE')
26
         commit('CLEAR_SINGLE_PAGE')
27
         commit('PAGES_LOADED', false)
27
         commit('PAGES_LOADED', false)
28
-        api.getSingleType('pages', id, page => {
28
+        api.getSingleType('page', id, page => {
29
             commit('STORE_FETCHED_SINGLE_PAGE', page)
29
             commit('STORE_FETCHED_SINGLE_PAGE', page)
30
             commit('PAGES_LOADED', true)
30
             commit('PAGES_LOADED', true)
31
         })
31
         })

+ 2
- 2
vue-theme/src/store/modules/post.js View File

15
     getAllPosts({ commit }, sortType) {
15
     getAllPosts({ commit }, sortType) {
16
         commit('CLEAR_POSTS')
16
         commit('CLEAR_POSTS')
17
         commit('POSTS_LOADED', false)
17
         commit('POSTS_LOADED', false)
18
-        return api.getByType('posts', sortType, posts => {
18
+        return api.getByType('post', sortType, posts => {
19
             commit('STORE_FETCHED_POSTS', { posts })
19
             commit('STORE_FETCHED_POSTS', { posts })
20
             commit('POSTS_LOADED', true)
20
             commit('POSTS_LOADED', true)
21
         })
21
         })
23
     getSinglePost({ commit }, id) {
23
     getSinglePost({ commit }, id) {
24
         commit('CLEAR_SINGLE_POSTS')
24
         commit('CLEAR_SINGLE_POSTS')
25
         commit('POSTS_LOADED', false)
25
         commit('POSTS_LOADED', false)
26
-        api.getSingleType('posts', id, post => {
26
+        api.getSingleType('post', id, post => {
27
             commit('STORE_FETCHED_SINGLE_POST', post)
27
             commit('STORE_FETCHED_SINGLE_POST', post)
28
             commit('POSTS_LOADED', true)
28
             commit('POSTS_LOADED', true)
29
         })
29
         })

+ 1
- 1
vue-theme/src/utils/api.js View File

64
     },
64
     },
65
     getPosts(limit = 5, cb) {
65
     getPosts(limit = 5, cb) {
66
         axios
66
         axios
67
-            .get(SETTINGS.API_BASE_PATH + 'posts')
67
+            .get(SETTINGS.API_BASE_PATH + 'post')
68
             .then(response => {
68
             .then(response => {
69
                 cb(response.data)
69
                 cb(response.data)
70
             })
70
             })

+ 7
- 7
vue-theme/src/utils/helpers.js View File

26
  */
26
  */
27
 const postTypes = [
27
 const postTypes = [
28
     'sticky',
28
     'sticky',
29
-    'episodes',
30
-    'artists',
31
-    'exhibitions',
32
-    'events',
33
-    'posts',
34
-    'pages',
29
+    'episode',
30
+    'artist',
31
+    'exhibition',
32
+    'event',
33
+    'post',
34
+    'page',
35
 ]
35
 ]
36
 
36
 
37
 /**
37
 /**
50
 
50
 
51
         // Only take the first match
51
         // Only take the first match
52
         type = type[0]
52
         type = type[0]
53
-        // console.log(`type derived from route.path: ${type}`)
53
+        console.log(`type derived from route.path: ${type}`)
54
     }
54
     }
55
 
55
 
56
     return type
56
     return type

Loading…
Cancel
Save