import {
  defineComponent, ref,
} from 'vue'
import type { IMetaTags } from '@model'
import { tools } from '@tools'
import { useQuasar } from 'quasar'
import { useMeta } from 'quasar'

// You can declare a mixin as the same style as components.
export default function () {

  function setmeta(mym: IMetaTags) {
    // cancellarlo...
    return
  }

  function getMeta(mym: IMetaTags, t: any) {

    //++Todo META TAGS!
    if (!mym || !mym.title)
      return

    return {
      title: t('ws.sitename'),
      titleTemplate: (title: any) => `${tools.getsuffisso()} ${mym.title} - ${t('ws.sitename')}`,
      meta: {
        keywords: {
          name: 'keywords',
          content: mym.keywords,
        },
        description: {
          name: 'description',
          content: mym.description,
        },
        equiv: { 'http-equiv': 'Content-Type', 'content': 'text/html; charset=UTF-8' },
      },
    }

  }

  function getsrcbyimg(myimg: string) {
    // return src
    const filefull = tools.getimgFullpathbysize(myimg)

    return tools.getimgbysize(filefull.path, filefull.file)
  }

  return {
    setmeta,
    getsrcbyimg,
    getMeta,
  }
}
