Explorar el Código

:sparkles: formatting all exhibition dates and event date-times | #76

tags/0.9.0
J hace 4 años
padre
commit
d1d62111a1

+ 8
- 1
vue-theme/src/components/card.vue Ver fichero

5
             p.t-up {{type}}
5
             p.t-up {{type}}
6
         router-link(v-else-if="!hideType" :to="`/${type}`")
6
         router-link(v-else-if="!hideType" :to="`/${type}`")
7
             p.t-up {{type}}
7
             p.t-up {{type}}
8
+
8
     article.card--info(:class="{ 'wide': wide }")
9
     article.card--info(:class="{ 'wide': wide }")
9
         router-link(:to="`/${type}/${content.slug}`")
10
         router-link(:to="`/${type}/${content.slug}`")
10
             //- set image to thumbnail setting
11
             //- set image to thumbnail setting
12
         .f-col.w-max
13
         .f-col.w-max
13
             router-link(:to="`/${type}/${content.slug}`")
14
             router-link(:to="`/${type}/${content.slug}`")
14
                 h1.t-up.t-cntr.t-b {{ content.title }}
15
                 h1.t-up.t-cntr.t-b {{ content.title }}
15
-            p(v-if="content.end") {{ new Date(content.start * 1000).toLocaleDateString() }} – {{ new Date(content.end * 1000).toLocaleDateString() }}
16
+            p(v-if="content.end") {{ dateFrom(content.start) }} – {{ dateFrom(content.end) }}
16
             p {{ content.excerpt }}
17
             p {{ content.excerpt }}
17
 </template>
18
 </template>
18
 
19
 
21
 export default {
22
 export default {
22
     components: { featuredImage },
23
     components: { featuredImage },
23
     props: ['type', 'content', 'wide', 'hide-type'],
24
     props: ['type', 'content', 'wide', 'hide-type'],
25
+    methods: {
26
+        dateFrom(unix, includeTime) {
27
+            const f = includeTime ? 'dd-m-yy h:MM' : 'dd-m-yy'
28
+            return new Date(parseInt(unix) * 1000).format(f)
29
+        }
30
+    }
24
 }
31
 }
25
 </script>
32
 </script>
26
 
33
 

+ 5
- 1
vue-theme/src/components/sidebars/events.vue Ver fichero

6
         featured-image(:post="post", thumbsize="'standard'")
6
         featured-image(:post="post", thumbsize="'standard'")
7
         router-link(:to="`/event/${post.slug}`")
7
         router-link(:to="`/event/${post.slug}`")
8
             p.t-up {{ post.title }}
8
             p.t-up {{ post.title }}
9
-        p {{ post.start }} &ndash; {{ post.end }}
9
+        p {{ dateFrom(post.start, true) }} &ndash; {{ dateFrom(post.end, true) }}
10
 </template>
10
 </template>
11
 
11
 
12
 <script>
12
 <script>
31
         }
31
         }
32
     },
32
     },
33
     methods: {
33
     methods: {
34
+        dateFrom(unix, includeTime) {
35
+            const f = includeTime ? 'dd-m-yy h:MM' : 'dd-m-yy'
36
+            return new Date(parseInt(unix) * 1000).format(f)
37
+        },
34
         async getPosts() {
38
         async getPosts() {
35
             this.$store.commit('CLEAR_EVENTS')
39
             this.$store.commit('CLEAR_EVENTS')
36
             const upcoming = this.$store.dispatch(
40
             const upcoming = this.$store.dispatch(

+ 5
- 1
vue-theme/src/components/sidebars/exhibitions.vue Ver fichero

6
         featured-image(:post="post", thumbsize="'standard'")
6
         featured-image(:post="post", thumbsize="'standard'")
7
         router-link(:to="`/exhibition/${post.slug}`")
7
         router-link(:to="`/exhibition/${post.slug}`")
8
             p.t-up {{ post.title }}
8
             p.t-up {{ post.title }}
9
-        p {{ post.start }} &ndash; {{ post.end }}
9
+        p {{ dateFrom(post.start, false) }} &ndash; {{ dateFrom(post.end, false) }}
10
 </template>
10
 </template>
11
 
11
 
12
 <script>
12
 <script>
31
         }
31
         }
32
     },
32
     },
33
     methods: {
33
     methods: {
34
+        dateFrom(unix, includeTime) {
35
+            const f = includeTime ? 'dd-m-yy h:MM' : 'dd-m-yy'
36
+            return new Date(parseInt(unix) * 1000).format(f)
37
+        },
34
         async getPosts() {
38
         async getPosts() {
35
             this.$store.commit('CLEAR_EXHIBITIONS')
39
             this.$store.commit('CLEAR_EXHIBITIONS')
36
             const upcoming = this.$store.dispatch(
40
             const upcoming = this.$store.dispatch(

+ 2
- 9
vue-theme/src/components/sidebars/sidebar.vue Ver fichero

46
         slot
46
         slot
47
 
47
 
48
         //- single layout Exhibitions sidebar
48
         //- single layout Exhibitions sidebar
49
-        .shadow(v-if="type === 'exhibition' && layout === 'single'")
49
+        .shadow(v-if="type === 'exhibition'")
50
             events-sidebar
50
             events-sidebar
51
         //- single layout Events sindebar
51
         //- single layout Events sindebar
52
-        .shadow(v-if="type === 'event' && layout === 'single'")
53
-            exhibitions-sidebar
54
-
55
-        //- list layout Exhibition sidebar show events
56
-        .shadow(v-if="type === 'exhibition' && layout === 'list'")
57
-            events-sidebar
58
-        //- list layout Events sidebar show exhibitions
59
-        .shadow(v-if="type === 'event' && layout === 'list'")
52
+        .shadow(v-if="type === 'event'")
60
             exhibitions-sidebar
53
             exhibitions-sidebar
61
 
54
 
62
 </template>
55
 </template>

+ 5
- 4
vue-theme/src/pages/single.vue Ver fichero

16
             //- p(v-if="singlePost.subtypes") subtypes: {{ singlePost.subtypes }}
16
             //- p(v-if="singlePost.subtypes") subtypes: {{ singlePost.subtypes }}
17
 
17
 
18
             .date-info(v-if="['exhibition', 'event'].includes(type)")
18
             .date-info(v-if="['exhibition', 'event'].includes(type)")
19
-                p start: {{ dateFrom(singlePost.start) }}
20
-                p end: {{ dateFrom(singlePost.end) }}
19
+                p start: {{ dateFrom(singlePost.start, type == 'event') }}
20
+                p end: {{ dateFrom(singlePost.end, type == 'event') }}
21
 
21
 
22
         //- WP main content
22
         //- WP main content
23
         section.content(v-html="singlePost.content")
23
         section.content(v-html="singlePost.content")
176
         /**
176
         /**
177
          * Date Object from unix strings from db
177
          * Date Object from unix strings from db
178
          */
178
          */
179
-        dateFrom(unix) {
180
-            return new Date(parseInt(unix) * 1000)
179
+        dateFrom(unix, includeTime) {
180
+            const f = includeTime ? 'dd-m-yy h:MM' : 'dd-m-yy'
181
+            return new Date(parseInt(unix) * 1000).format(f)
181
         },
182
         },
182
 
183
 
183
         async loadPostData() {
184
         async loadPostData() {

Loading…
Cancelar
Guardar