move date/month to computed

This commit is contained in:
2023-02-27 23:18:58 +10:00
parent 91a4a2c2a4
commit 62a3180e53

View File

@@ -3,10 +3,10 @@
<div v-if="image" class="sm-panel-image" :style="styleObject"> <div v-if="image" class="sm-panel-image" :style="styleObject">
<div v-if="dateInImage && date" class="sm-panel-image-date"> <div v-if="dateInImage && date" class="sm-panel-image-date">
<div class="sm-panel-image-date-day"> <div class="sm-panel-image-date-day">
{{ new SMDate(date, { format: "yMd" }).format("dd") }} {{ computedDay }}
</div> </div>
<div class="sm-panel-image-date-month"> <div class="sm-panel-image-date-month">
{{ new SMDate(date, { format: "yMd" }).format("MMM") }} {{ computedMonth }}
</div> </div>
</div> </div>
<ion-icon <ion-icon
@@ -145,30 +145,30 @@ let imageUrl = ref("");
const computedDate = computed(() => { const computedDate = computed(() => {
let str = ""; let str = "";
// if (props.date.length > 0) { if (props.date.length > 0) {
// if ( if (
// (props.endDate.length > 0 && (props.endDate.length > 0 &&
// props.date.substring(0, props.date.indexOf(" ")) != props.date.substring(0, props.date.indexOf(" ")) !=
// props.endDate.substring(0, props.endDate.indexOf(" "))) || props.endDate.substring(0, props.endDate.indexOf(" "))) ||
// props.showTime == false props.showTime == false
// ) { ) {
// str = new SMDate(props.date, { format: "yMd" }).format( str = new SMDate(props.date, { format: "yMd" }).format(
// "dd/MM/yyyy" "dd/MM/yyyy"
// ); );
// if (props.endDate.length > 0) { if (props.endDate.length > 0) {
// str = str =
// str + str +
// " - " + " - " +
// new SMDate(props.endDate, { format: "yMd" }).format( new SMDate(props.endDate, { format: "yMd" }).format(
// "dd/MM/yyyy" "dd/MM/yyyy"
// ); );
// } }
// } else { } else {
// str = new SMDate(props.endDate, { format: "yMd" }).format( str = new SMDate(props.endDate, { format: "yMd" }).format(
// "dd/MM/yyyy @ h:mm aa" "dd/MM/yyyy @ h:mm aa"
// ); );
// } }
// } }
return str; return str;
}); });
@@ -180,6 +180,14 @@ const computedContent = computed(() => {
return excerpt(replaceHtmlEntites(stripHtmlTags(props.content)), 200); return excerpt(replaceHtmlEntites(stripHtmlTags(props.content)), 200);
}); });
const computedDay = computed(() => {
return new SMDate(props.date, { format: "yMd" }).format("dd");
});
const computedMonth = computed(() => {
return new SMDate(props.date, { format: "yMd" }).format("MMM");
});
onMounted(async () => { onMounted(async () => {
if (props.image && props.image.length > 0 && isUUID(props.image)) { if (props.image && props.image.length > 0 && isUUID(props.image)) {
api.get({ url: "/media/{medium}", params: { medium: props.image } }) api.get({ url: "/media/{medium}", params: { medium: props.image } })