ProseA.vue 762 B

123456789101112131415161718192021222324252627282930313233
  1. <script setup lang="ts">
  2. const props = defineProps<
  3. {
  4. href: string
  5. target: '_blank' | '_parent' | '_self' | '_top' | (string & object) | null | undefined
  6. }
  7. >()
  8. const type = computed(() => {
  9. if (props.href.startsWith('https://github.com/')) {
  10. return 'github-at'
  11. }
  12. return 'link'
  13. })
  14. </script>
  15. <template>
  16. <GithubMagicLink
  17. v-if="type === 'github-at'"
  18. :href="href"
  19. target="_blank"
  20. >
  21. <slot></slot>
  22. </GithubMagicLink>
  23. <NuxtLink
  24. v-else
  25. class="text-primary border-b border-transparent hover:border-primary font-medium focus-visible:outline-primary [&>code]:border-dashed hover:[&>code]:border-primary hover:[&>code]:text-primary"
  26. :href="href"
  27. :target="target"
  28. >
  29. <slot></slot>
  30. </NuxtLink>
  31. </template>