|
|
@@ -3,25 +3,20 @@
|
|
3
|
3
|
article.f-grow
|
|
4
|
4
|
header.f-row.center.t-up
|
|
5
|
5
|
h1 {{ type }} list
|
|
|
6
|
+ h3(v-if="!loaded") loading...
|
|
6
|
7
|
span(v-if="sortBy")
|
|
7
|
8
|
h1 sorted by {{ sortBy.replace('-', ' ') }}
|
|
8
|
9
|
|
|
9
|
|
- .posts(v-if="posts" :class="{ 'is-grid': grid }")
|
|
|
10
|
+ .posts(v-if="posts && loaded" :class="{ 'is-grid': grid }")
|
|
10
|
11
|
section(v-for="post in posts" :key="post.slug").shadow.post
|
|
11
|
|
- router-link(:to="`/${type}/${post.slug}`")
|
|
12
|
|
- p {{post.featured}}
|
|
13
|
|
- ul.f-row
|
|
14
|
|
- img(v-if="post.featured" :src="post.featured" alt="post thumbnail")
|
|
15
|
|
- img(v-else-if="JSON.parse(post.hero) && JSON.parse(post.hero).url" :src="getThumbnailFromYt(JSON.parse(post.hero).url)" alt="post thumbnail from YouTube")
|
|
16
|
|
- p(v-else-if="post.hero") ERROR: {{ post.hero }}
|
|
17
|
|
- p(v-else) ERROR: no thumbnail
|
|
18
|
|
- li.f-col.between
|
|
19
|
|
- h2.t-up {{ post.title }}
|
|
20
|
|
- h4 {{ post.date }}
|
|
21
|
|
- p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eu elit in ex pharetra volutpat ac at magna. Duis libero est, imperdiet non sollicitudin vel, eleifend at ante...
|
|
|
12
|
+ header
|
|
|
13
|
+ router-link(:to="`/${type}/${post.slug}`")
|
|
|
14
|
+ featured-image(:post="post")
|
|
|
15
|
+ h2.t-up {{ post.title }}
|
|
|
16
|
+ article
|
|
|
17
|
+ h4 {{ post.date }}
|
|
|
18
|
+ p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras eu elit in ex pharetra volutpat ac at magna. Duis libero est, imperdiet non sollicitudin vel, eleifend at ante...
|
|
22
|
19
|
|
|
23
|
|
- //- posts not grid
|
|
24
|
|
-
|
|
25
|
20
|
footer
|
|
26
|
21
|
p {{ `${type} count: ${Object.values(posts).length}` }}
|
|
27
|
22
|
p {{ `show sidebar: ${sidebar}` }}
|
|
|
@@ -35,13 +30,14 @@
|
|
35
|
30
|
</template>
|
|
36
|
31
|
|
|
37
|
32
|
<script>
|
|
|
33
|
+import featuredImage from '@/components/featured-image'
|
|
38
|
34
|
import sidebar from '@/components/sidebars/sidebar'
|
|
39
|
35
|
import { postTypeGetters, scrollTop } from './mixin-post-types'
|
|
40
|
36
|
|
|
41
|
37
|
import { convertTitleCase, typeFromRoute, sortTypes, ytThumbnail } from '@/utils/helpers'
|
|
42
|
38
|
|
|
43
|
39
|
export default {
|
|
44
|
|
- components: { sidebar },
|
|
|
40
|
+ components: { sidebar, featuredImage },
|
|
45
|
41
|
props: {
|
|
46
|
42
|
sidebar: { type: Boolean },
|
|
47
|
43
|
grid: { type: Boolean },
|
|
|
@@ -56,6 +52,11 @@ export default {
|
|
56
|
52
|
let type = convertTitleCase(this.type)
|
|
57
|
53
|
return this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
|
|
58
|
54
|
},
|
|
|
55
|
+ loaded() {
|
|
|
56
|
+ let type = convertTitleCase(this.type)
|
|
|
57
|
+ if(!type) return
|
|
|
58
|
+ return this[`all${type}Loaded`]
|
|
|
59
|
+ },
|
|
59
|
60
|
posts() {
|
|
60
|
61
|
let type = convertTitleCase(this.type)
|
|
61
|
62
|
if(!type) return
|
|
|
@@ -85,11 +86,11 @@ export default {
|
|
85
|
86
|
|
|
86
|
87
|
// Sorting
|
|
87
|
88
|
let sort = this.sortBy ? this.sortBy : this.$route.path.split('/').pop()
|
|
|
89
|
+
|
|
88
|
90
|
if(Object.values(sortTypes).includes(sort)) {
|
|
89
|
91
|
console.log('trying to sort by:', sort)
|
|
90
|
92
|
console.log(`sortTypes includes ${sort}:`, Object.values(sortTypes).includes(sort))
|
|
91
|
93
|
}
|
|
92
|
|
-
|
|
93
|
94
|
// Is this a sort type?
|
|
94
|
95
|
if(this.type !== sort || !Object.values(sortTypes).includes(sort)) sort = null
|
|
95
|
96
|
|
|
|
@@ -113,7 +114,6 @@ export default {
|
|
113
|
114
|
created() {
|
|
114
|
115
|
let type = convertTitleCase(this.type)
|
|
115
|
116
|
// console.log('already loaded ?:', this[`all${type}Loaded`])
|
|
116
|
|
-
|
|
117
|
117
|
if(!this[`all${type}Loaded`]) this.setHeroAndGetPosts()
|
|
118
|
118
|
}
|
|
119
|
119
|
}
|