2019-12-05 06:46:19 -05:00
|
|
|
<template>
|
|
|
|
<article :class="articleClass">
|
2019-12-18 08:54:22 -05:00
|
|
|
<a v-if="cardData.coverImage" class="post-card-image-link" :href="cardData.path">
|
2019-12-05 06:46:19 -05:00
|
|
|
<!-- FIXME Background size cover -->
|
2019-12-19 11:31:35 -05:00
|
|
|
<div class="post-card-image" :style="'background-image: url(' + cardData.coverImage + ')'|changeUrls"></div>
|
2019-12-05 06:46:19 -05:00
|
|
|
</a>
|
|
|
|
<div class="post-card-content">
|
|
|
|
<a class="post-card-content-link" :href="cardData.path">
|
|
|
|
<header class="post-card-header">
|
|
|
|
<span
|
|
|
|
v-if="cardData.tags"
|
|
|
|
class="post-card-tags"
|
2019-12-18 08:54:22 -05:00
|
|
|
>{{ cardData.tags[0].name.replace('-', ' ') }}</span>
|
2019-12-05 06:46:19 -05:00
|
|
|
<h2 class="post-card-title">{{ cardData.title }}</h2>
|
|
|
|
</header>
|
|
|
|
<section class="post-card-excerpt">
|
2019-12-19 11:31:35 -05:00
|
|
|
<p>{{ cardData.description | stripHTML | changeUrls | truncate(190, '...') }}</p>
|
2019-12-05 06:46:19 -05:00
|
|
|
</section>
|
|
|
|
</a>
|
|
|
|
<footer class="post-card-meta">
|
|
|
|
<ul class="author-list">
|
2019-12-18 08:54:22 -05:00
|
|
|
<li v-for="author in cardData.authors" class="author-list-item" :key="author.slug">
|
2019-12-05 06:46:19 -05:00
|
|
|
<div class="author-name-tooltip">{{ author.name }}</div>
|
2019-12-18 08:54:22 -05:00
|
|
|
<a v-if="author.image" :href="'/author/' + author.slug" class="static-avatar">
|
2019-12-19 11:31:35 -05:00
|
|
|
<img class="author-profile-image" :src="author.image|changeUrls" :alt="author.name" />
|
2019-12-05 06:46:19 -05:00
|
|
|
</a>
|
2019-12-18 08:54:22 -05:00
|
|
|
<a v-else :href="'/author/' + author.slug" class="static-avatar author-profile-image">
|
2019-12-05 06:46:19 -05:00
|
|
|
<Avatar/>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2019-12-30 07:09:01 -05:00
|
|
|
<span class="reading-time">{{ readingTime }}</span>
|
2019-12-05 06:46:19 -05:00
|
|
|
</footer>
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Avatar from "./icons/Avatar";
|
2019-12-19 11:31:35 -05:00
|
|
|
import changeUrls from '../filters/changeUrls';
|
2019-12-30 07:09:01 -05:00
|
|
|
import { readingTime as readingTimeHelper } from '@tryghost/helpers'
|
2019-12-05 06:46:19 -05:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
Avatar
|
|
|
|
},
|
|
|
|
props: {
|
2019-12-24 03:17:40 -05:00
|
|
|
cardData: Object,
|
|
|
|
isLarge: Boolean
|
2019-12-05 06:46:19 -05:00
|
|
|
},
|
|
|
|
computed: {
|
2019-12-30 07:09:01 -05:00
|
|
|
readingTime() {
|
|
|
|
return readingTimeHelper({
|
|
|
|
html: this.cardData.content,
|
|
|
|
feature_image: this.cardData.coverImage
|
|
|
|
})
|
|
|
|
},
|
2019-12-05 06:46:19 -05:00
|
|
|
articleClass() {
|
|
|
|
let classes = ["post-card", "post"];
|
|
|
|
if (this.cardData.fields === null) {
|
|
|
|
classes.push("no-image");
|
|
|
|
}
|
2019-12-18 08:54:22 -05:00
|
|
|
for (var i=0;i<this.cardData.tags.length;i++) {
|
|
|
|
var cardTagClass = "post-" + this.cardData.tags[i].slug;
|
|
|
|
classes.push(cardTagClass);
|
|
|
|
}
|
2019-12-24 03:17:40 -05:00
|
|
|
if (this.isLarge) {
|
|
|
|
classes.push("post-card-large");
|
|
|
|
}
|
2019-12-05 06:46:19 -05:00
|
|
|
return classes;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
truncate: (text, length, suffix) => {
|
2019-12-18 08:54:22 -05:00
|
|
|
if (!text) return text
|
2019-12-24 03:21:38 -05:00
|
|
|
if (text.length <= length) return text
|
2019-12-05 06:46:19 -05:00
|
|
|
return text.substring(0, length) + suffix;
|
|
|
|
},
|
|
|
|
stripHTML: text => {
|
2019-12-18 08:54:22 -05:00
|
|
|
if (!text) return text
|
2019-12-05 06:46:19 -05:00
|
|
|
return text.replace(/<[^>]+>/g, '')
|
2019-12-19 11:31:35 -05:00
|
|
|
},
|
|
|
|
changeUrls: changeUrls
|
2019-12-05 06:46:19 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|