ReadMore.vue 820 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <script setup lang="ts">
  2. import { splitByCase, upperFirst } from 'scule'
  3. const props = defineProps<{
  4. to: string
  5. title: string
  6. }>()
  7. const createBreadcrumb = (link: string = 'Missing link') => {
  8. if (link.startsWith('http')) {
  9. return link
  10. }
  11. return link
  12. .split('/')
  13. .filter(Boolean)
  14. .map(part =>
  15. splitByCase(part)
  16. .map(p => upperFirst(p))
  17. .join(' '),
  18. )
  19. .join(' > ')
  20. .replace('Api', 'API')
  21. }
  22. const computedTitle = computed<string>(() => props.title || createBreadcrumb(props.to))
  23. </script>
  24. <template>
  25. <ProseCallout
  26. icon="i-lucide-bookmark"
  27. :to="to"
  28. :aria-label="computedTitle"
  29. >
  30. <slot mdc-unwrap="p">
  31. Read more in <span
  32. class="font-bold"
  33. v-text="computedTitle"
  34. ></span>.
  35. </slot>
  36. </ProseCallout>
  37. </template>