<template>
  <component :is="type" v-bind="linkProps(path)">
    <slot />
  </component>
</template>

<script>
export default {
  props: {
    menuType: {
      type: String,
      require: true
    },
    path: {
      type: String,
      required: true
    }
  },
  computed: {
    type() {
      if (this.menuType === 'link_inner' || this.menuType === 'link_outer') {
        return 'a'
      }
      return 'router-link'
    }
  },
  methods: {
    linkProps() {
      if (this.menuType === 'link_outer') {
        return {
          href: this.path,
          target: '_blank',
          rel: 'noopener'
        }
      } else if (this.menuType === 'link_inner') {
        return {
          href: this.path
        }
      } else {
        return {
          to: this.path
        }
      }
    }
  }
}
</script>
