filters.js 405 B

12345678910111213141516
  1. import Vue from 'vue'
  2. import moment from 'moment'
  3. Vue.filter('shortenText',function(text, maxLength = 300){
  4. if(text && typeof text === 'string'){
  5. const finalChar = text.length > maxLength ? '...' : ''
  6. return text.substr(0, maxLength) + finalChar
  7. }
  8. return ''
  9. })
  10. Vue.filter('formatDate', function(date, dateFormat = 'LL') {
  11. if (!date) return ''
  12. return moment(date).format(dateFormat)
  13. })