vp-page-nav.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <script setup lang="ts">
  2. import { withBase } from 'vitepress'
  3. import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
  4. import { usePageNav } from '../../composables/page-nav'
  5. const { hasLinks, prev, next } = usePageNav()
  6. </script>
  7. <template>
  8. <div v-if="hasLinks" class="next-and-prev-link">
  9. <div class="container">
  10. <div class="prev">
  11. <a v-if="prev" class="link" :href="withBase(prev.link)">
  12. <ElIcon class="mr-1">
  13. <ArrowLeft />
  14. </ElIcon>
  15. <span class="text">{{ prev.text }}</span>
  16. </a>
  17. </div>
  18. <div class="next">
  19. <a v-if="next" class="link" :href="withBase(next.link)">
  20. <span class="text">{{ next.text }}</span>
  21. <ElIcon class="ml-1">
  22. <ArrowRight />
  23. </ElIcon>
  24. </a>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <style scoped>
  30. .next-and-prev-link {
  31. padding-top: 1rem;
  32. }
  33. .container {
  34. display: flex;
  35. justify-content: space-between;
  36. border-top: 1px solid var(--border-color);
  37. padding-top: 1rem;
  38. }
  39. .prev,
  40. .next {
  41. display: flex;
  42. flex-shrink: 0;
  43. width: 50%;
  44. }
  45. .prev {
  46. justify-content: flex-start;
  47. padding-right: 12px;
  48. }
  49. .next {
  50. justify-content: flex-end;
  51. padding-left: 12px;
  52. }
  53. .link {
  54. display: inline-flex;
  55. justify-content: center;
  56. align-items: center;
  57. max-width: 100%;
  58. height: 24px;
  59. font-size: 14px;
  60. font-weight: 500;
  61. }
  62. .text {
  63. display: inline-flex;
  64. white-space: nowrap;
  65. overflow: hidden;
  66. text-overflow: ellipsis;
  67. }
  68. .el-icon {
  69. display: inline-flex;
  70. flex-shrink: 0;
  71. font-size: 12px;
  72. color: var(--text-color);
  73. transform: translateY(1px);
  74. }
  75. .icon-prev {
  76. margin-right: 8px;
  77. }
  78. .icon-next {
  79. margin-left: 8px;
  80. }
  81. </style>