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,7 +85,6 @@ export default {
85 85
         }
86 86
     },
87 87
     created() {
88
-        console.log(this)
89 88
         this.setHeroAndGetPosts()
90 89
     }
91 90
 }

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

@@ -1,6 +1,10 @@
1 1
 import { convertTitleCase } from '@/utils/helpers'
2 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 8
 const postTypes = [
5 9
     'post',
6 10
     'page',
@@ -10,6 +14,11 @@ const postTypes = [
10 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 22
 const getterHelper = {}
14 23
 for(let type of postTypes) {
15 24
     const capitalized = convertTitleCase(type)

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

@@ -5,6 +5,10 @@
5 5
             h1 {{ type }}:{{ $route.params.slug }} {{ post.title }}
6 6
             p(v-if="post.categories") categories: {{ post.categories }}
7 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 13
         .post-single.block-wrapper(v-for="(block, i) in post.blocks" :key="`block-${i}`")
10 14
             //- ?: are objects are always gallery blocks
@@ -56,7 +60,6 @@ export default {
56 60
         type() { // Checks for type and fixes Episodes route edge case 
57 61
             return typeFromRoute(this.$route)
58 62
         },
59
-
60 63
         /**
61 64
          * We get the actual post data using the slug
62 65
          */
@@ -127,7 +130,14 @@ export default {
127 130
 
128 131
             const json = JSON.parse(post.hero)
129 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 142
     watch: {
133 143
         posts(newVal, oldVal) {

Loading…
Annulla
Salva