Переглянути джерело

:recycle: adding credits only to single episode endpoint | added credits component for frontend

tags/0.9.0
TOJ 5 роки тому
джерело
коміт
7e195d65e7

+ 1
- 0
plugins/cia-endpoints/includes/class.make-endpoint.php Переглянути файл

@@ -103,6 +103,7 @@ class Make_Endpoint_For extends WP_REST_Controller {
103 103
             foreach ( get_attached_media( '', $item->ID ) as $attached_media ):
104 104
                 array_push($media_ids, $attached_media->ID);
105 105
             endforeach;
106
+
106 107
             $filtered[galleries] = get_ids_from_gallery_block(
107 108
                 parse_blocks( $item->post_content )
108 109
             );

+ 0
- 2
plugins/cia-endpoints/includes/formats.php Переглянути файл

@@ -31,8 +31,6 @@ function default_post_format( $item ) {
31 31
     // Custom fields endpoint
32 32
     if($item->post_type === 'artist') $filtered[sortname] = get_post_meta( $item->ID, 'artist-sort-name', true );
33 33
 
34
-    if($item->post_type === 'episode') $filtered[credits] = get_post_meta( $item->ID, 'credits', true );
35
-
36 34
     if($item->post_type === 'event') {
37 35
         $filtered[start] = get_post_meta( $item->ID, 'event-start-time', true );
38 36
         $filtered[end] = get_post_meta( $item->ID, 'event-end-time', true );

+ 17
- 0
vue-theme/src/components/credits.vue Переглянути файл

@@ -0,0 +1,17 @@
1
+<template lang="pug">
2
+.credits
3
+    h2.t-up credits
4
+    div(v-html="post.credits")
5
+</template>
6
+
7
+<script>
8
+export default {
9
+    props: {
10
+        post: { required: true }
11
+    }
12
+}
13
+</script>
14
+
15
+<style lang="postcss">
16
+.credits
17
+</style>

+ 9
- 5
vue-theme/src/pages/single.vue Переглянути файл

@@ -8,12 +8,15 @@
8 8
             h1 {{ type }}:{{ $route.params.slug }} {{ post.title }}
9 9
             p(v-if="post.categories") categories: {{ post.categories }}
10 10
             p(v-if="post.type") type: {{ post.type }}
11
+
11 12
             .date-info(v-if="type === 'events' || post.type === 'exhibitions'")
12 13
                 p start: {{ dateFrom(post.start) }}
13 14
                 p end: {{ dateFrom(post.end) }}
14 15
 
15 16
         block.post-single.block-wrapper(v-for="(block, index) in post.blocks" :block="block" :key="`block-${index}`")
16 17
 
18
+        credits(v-if="type === 'episodes'" :post="post")
19
+
17 20
     sidebar(v-if="sidebar" :type="`${type}`")
18 21
         .shadow
19 22
             h1.t-up single slot
@@ -25,13 +28,14 @@
25 28
 import sidebar from '@/components/sidebars/sidebar'
26 29
 import gallery from '@/components/gallery/'
27 30
 import block from '@/components/content-block/block'
31
+import credits from '@/components/credits'
28 32
 
29 33
 import { postTypeGetters } from './mixin-post-types'
30 34
 
31 35
 import { convertTitleCase, dePluralize, typeFromRoute } from '@/utils/helpers'
32 36
 
33 37
 export default {
34
-    components: { sidebar, gallery, block },
38
+    components: { sidebar, gallery, block, credits },
35 39
     props: {
36 40
         sidebar: { type: Boolean },
37 41
         id: { type: Number }
@@ -53,12 +57,12 @@ export default {
53 57
          */
54 58
         post() {
55 59
             if(!this[this.type]) return
56
-            
60
+
57 61
             const type = dePluralize(this.type)
58 62
 
59 63
             // State not a getter!
60 64
             const singleOfTypeFromState = this[this.type][`single${convertTitleCase(type)}`]
61
-            
65
+
62 66
             if(!singleOfTypeFromState) return
63 67
 
64 68
             return singleOfTypeFromState
@@ -139,7 +143,7 @@ export default {
139 143
          */
140 144
         let type = convertTitleCase(this.type)
141 145
         let allPostsOfType = this.$store.state[this.type].all
142
-        
146
+
143 147
         /**
144 148
          * Load posts if they're not already in state
145 149
          */
@@ -149,7 +153,7 @@ export default {
149 153
             console.log(`reloaded ${type}...`)
150 154
         }
151 155
         const singlePostData = Object.values(allPostsOfType).filter(post => post.slug == this.$route.params.slug)[0]
152
- 
156
+
153 157
         await this.$store.dispatch(`getSingle${dePluralize(type)}`, singlePostData.id)
154 158
     }
155 159
 }

Завантаження…
Відмінити
Зберегти