Sfoglia il codice sorgente

:sparkles: displaying start and end time | converting unix to js date objects

tags/0.9.0
j 5 anni fa
parent
commit
fef72a401c

+ 0
- 1
vue-theme/src/pages/list.vue Vedi File

85
         }
85
         }
86
     },
86
     },
87
     created() {
87
     created() {
88
-        console.log(this)
89
         this.setHeroAndGetPosts()
88
         this.setHeroAndGetPosts()
90
     }
89
     }
91
 }
90
 }

+ 10
- 1
vue-theme/src/pages/mixin-post-types.js Vedi File

1
 import { convertTitleCase } from '@/utils/helpers'
1
 import { convertTitleCase } from '@/utils/helpers'
2
 import { mapGetters } from 'vuex'
2
 import { mapGetters } from 'vuex'
3
-
3
+/**
4
+ * A list of custom post types used to dispatch vuex actions
5
+ * This makes ALL post type modules available for the
6
+ * list and single components to request data
7
+ */
4
 const postTypes = [
8
 const postTypes = [
5
     'post',
9
     'post',
6
     'page',
10
     'page',
10
     'exhibition'
14
     'exhibition'
11
 ]
15
 ]
12
 
16
 
17
+/**
18
+ * Create an object to hold the action names
19
+ * Example: allArtists and allArtistsLoaded
20
+ * See modules folder
21
+ */
13
 const getterHelper = {}
22
 const getterHelper = {}
14
 for(let type of postTypes) {
23
 for(let type of postTypes) {
15
     const capitalized = convertTitleCase(type)
24
     const capitalized = convertTitleCase(type)

+ 12
- 2
vue-theme/src/pages/single.vue Vedi File

5
             h1 {{ type }}:{{ $route.params.slug }} {{ post.title }}
5
             h1 {{ type }}:{{ $route.params.slug }} {{ post.title }}
6
             p(v-if="post.categories") categories: {{ post.categories }}
6
             p(v-if="post.categories") categories: {{ post.categories }}
7
             p(v-if="post.type") type: {{ post.type }}
7
             p(v-if="post.type") type: {{ post.type }}
8
+            .date-info(v-if="type === 'events' || post.type === 'exhibitions'")
9
+                p start: {{ dateFrom(post.start) }}
10
+                p end: {{ dateFrom(post.end) }}
11
+
8
 
12
 
9
         .post-single.block-wrapper(v-for="(block, i) in post.blocks" :key="`block-${i}`")
13
         .post-single.block-wrapper(v-for="(block, i) in post.blocks" :key="`block-${i}`")
10
             //- ?: are objects are always gallery blocks
14
             //- ?: are objects are always gallery blocks
56
         type() { // Checks for type and fixes Episodes route edge case 
60
         type() { // Checks for type and fixes Episodes route edge case 
57
             return typeFromRoute(this.$route)
61
             return typeFromRoute(this.$route)
58
         },
62
         },
59
-
60
         /**
63
         /**
61
          * We get the actual post data using the slug
64
          * We get the actual post data using the slug
62
          */
65
          */
127
 
130
 
128
             const json = JSON.parse(post.hero)
131
             const json = JSON.parse(post.hero)
129
             this.$store.commit('SET_HERO', json)
132
             this.$store.commit('SET_HERO', json)
130
-        }
133
+        },
134
+
135
+        /**
136
+         * Date Object from unix strings from db
137
+         */
138
+        dateFrom(unix) {
139
+            return new Date( parseInt(unix) * 1000 )
140
+        },
131
     },
141
     },
132
     watch: {
142
     watch: {
133
         posts(newVal, oldVal) {
143
         posts(newVal, oldVal) {

Loading…
Annulla
Salva