<template>
  <ion-card :router-link="'/tabs/post_detail/'+obj.id" >
    <ion-img alt="Silhouette of mountains" :src="feature_img"  v-if="feature_img" class='img_16_9'/>
    <ion-card-header>
      <ion-card-title class='ion-text-start'>{{ obj.name }}</ion-card-title>
    </ion-card-header>

  </ion-card>
</template>

<script setup lang="ts">
  import { IonPage, IonHeader, IonToolbar, IonTitle, IonContent, IonIcon, onIonViewWillEnter, IonCard, IonCardHeader, IonCardTitle, IonCardSubtitle, IonCardContent, IonImg } from '@ionic/vue';

import { getTrainers, listCourses, BASE_URL } from '@/composable/settings';
  import { ref, onMounted } from 'vue'
  const props = defineProps({
    obj: Object,
  })
  const feature_img  = ref()
  onMounted(() => {
    console.log("--- onmounted ---")
    if( props.obj.feature_img && !props.obj.feature_img.startsWith('http') ) {
      feature_img.value = BASE_URL + props.obj.feature_img
    }else {
      feature_img.value = props.obj.feature_img
    }
  })
  const truncate = (str) => {
    return "T "+str
  }
</script>

<style scoped>
#container {
  background-color:#f00;
}
ion-card-title {
  font-size:1em;
}
.img-crop {
   aspect-ratio: 4/3 auto;
}
.img_16_9 {
  aspect-ratio: 16/9 auto;
  object-fit:cover;
}
</style>
