<!--
  @description 侧边栏链接组件，根据路由类型生成内部链接或外部链接
  @author D吕贺034244311
  @date 20260616
-->

<template>
  <a v-if="isExternal" :href="to" target="_blank" rel="noopener">
    <slot />
  </a>
  <router-link v-else :to="to">
    <slot />
  </router-link>
</template>

<script>
import { isExternal } from '@/utils/validate'

export default {
  props: {
    to: {
      type: String,
      required: true
    }
  },
  computed: {
    isExternal() {
      return isExternal(this.to)
    }
  }
}
</script>
