Просмотр исходного кода

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

tags/0.9.0
J 4 лет назад
Родитель
Сommit
d1d62111a1

+ 8
- 1
vue-theme/src/components/card.vue Просмотреть файл

@@ -5,6 +5,7 @@
5 5
             p.t-up {{type}}
6 6
         router-link(v-else-if="!hideType" :to="`/${type}`")
7 7
             p.t-up {{type}}
8
+
8 9
     article.card--info(:class="{ 'wide': wide }")
9 10
         router-link(:to="`/${type}/${content.slug}`")
10 11
             //- set image to thumbnail setting
@@ -12,7 +13,7 @@
12 13
         .f-col.w-max
13 14
             router-link(:to="`/${type}/${content.slug}`")
14 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 17
             p {{ content.excerpt }}
17 18
 </template>
18 19
 
@@ -21,6 +22,12 @@ import featuredImage from '@/components/featured-image'
21 22
 export default {
22 23
     components: { featuredImage },
23 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 32
 </script>
26 33
 

+ 5
- 1
vue-theme/src/components/sidebars/events.vue Просмотреть файл

@@ -6,7 +6,7 @@ ul.t-up
6 6
         featured-image(:post="post", thumbsize="'standard'")
7 7
         router-link(:to="`/event/${post.slug}`")
8 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 10
 </template>
11 11
 
12 12
 <script>
@@ -31,6 +31,10 @@ export default {
31 31
         }
32 32
     },
33 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 38
         async getPosts() {
35 39
             this.$store.commit('CLEAR_EVENTS')
36 40
             const upcoming = this.$store.dispatch(

+ 5
- 1
vue-theme/src/components/sidebars/exhibitions.vue Просмотреть файл

@@ -6,7 +6,7 @@ ul.t-up
6 6
         featured-image(:post="post", thumbsize="'standard'")
7 7
         router-link(:to="`/exhibition/${post.slug}`")
8 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 10
 </template>
11 11
 
12 12
 <script>
@@ -31,6 +31,10 @@ export default {
31 31
         }
32 32
     },
33 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 38
         async getPosts() {
35 39
             this.$store.commit('CLEAR_EXHIBITIONS')
36 40
             const upcoming = this.$store.dispatch(

+ 2
- 9
vue-theme/src/components/sidebars/sidebar.vue Просмотреть файл

@@ -46,17 +46,10 @@ aside.sidebar
46 46
         slot
47 47
 
48 48
         //- single layout Exhibitions sidebar
49
-        .shadow(v-if="type === 'exhibition' && layout === 'single'")
49
+        .shadow(v-if="type === 'exhibition'")
50 50
             events-sidebar
51 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 53
             exhibitions-sidebar
61 54
 
62 55
 </template>

+ 5
- 4
vue-theme/src/pages/single.vue Просмотреть файл

@@ -16,8 +16,8 @@
16 16
             //- p(v-if="singlePost.subtypes") subtypes: {{ singlePost.subtypes }}
17 17
 
18 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 22
         //- WP main content
23 23
         section.content(v-html="singlePost.content")
@@ -176,8 +176,9 @@ export default {
176 176
         /**
177 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 184
         async loadPostData() {

Загрузка…
Отмена
Сохранить