HomeFeatures.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <script setup lang="ts">
  2. import { computed } from 'vue'
  3. import { useData } from 'vitepress'
  4. const { frontmatter } = useData()
  5. const hasFeatures = computed(() => {
  6. return frontmatter.value.features && frontmatter.value.features.length > 0
  7. })
  8. interface Feature {
  9. title?: string
  10. details?: string
  11. }
  12. const features = computed<Feature[]>(() => {
  13. return frontmatter.value.features ? frontmatter.value.features : []
  14. })
  15. </script>
  16. <template>
  17. <div v-if="hasFeatures" class="home-features">
  18. <div class="wrapper">
  19. <div class="container">
  20. <div class="features">
  21. <section
  22. v-for="(feature, index) in features"
  23. :key="index"
  24. class="feature"
  25. >
  26. <h2 class="title" v-if="feature.title">{{ feature.title }}</h2>
  27. <p class="details" v-if="feature.details">{{ feature.details }}</p>
  28. </section>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <style scoped>
  35. .home-features {
  36. margin: 0 auto;
  37. padding: 2.5rem 0 2.75rem;
  38. max-width: 960px;
  39. }
  40. .home-hero + .home-features {
  41. padding-top: 0;
  42. }
  43. @media (min-width: 420px) {
  44. .home-features {
  45. padding: 3.25rem 0 3.5rem;
  46. }
  47. .home-hero + .home-features {
  48. padding-top: 0;
  49. }
  50. }
  51. @media (min-width: 720px) {
  52. .home-features {
  53. padding-right: 1.5rem;
  54. padding-left: 1.5rem;
  55. }
  56. }
  57. .wrapper {
  58. padding: 0 1.5rem;
  59. }
  60. .home-hero + .home-features .wrapper {
  61. border-top: 1px solid var(--c-divider);
  62. padding-top: 2.5rem;
  63. }
  64. @media (min-width: 420px) {
  65. .home-hero + .home-features .wrapper {
  66. padding-top: 3.25rem;
  67. }
  68. }
  69. @media (min-width: 720px) {
  70. .wrapper {
  71. padding-right: 0;
  72. padding-left: 0;
  73. }
  74. }
  75. .container {
  76. margin: 0 auto;
  77. max-width: 392px;
  78. }
  79. @media (min-width: 720px) {
  80. .container {
  81. max-width: 960px;
  82. }
  83. }
  84. .features {
  85. display: flex;
  86. flex-wrap: wrap;
  87. margin: -20px -24px;
  88. }
  89. .feature {
  90. flex-shrink: 0;
  91. padding: 20px 24px;
  92. width: 100%;
  93. }
  94. @media (min-width: 720px) {
  95. .feature {
  96. width: calc(100% / 3);
  97. }
  98. }
  99. .title {
  100. margin: 0;
  101. border-bottom: 0;
  102. line-height: 1.4;
  103. font-size: 1.25rem;
  104. font-weight: 500;
  105. }
  106. @media (min-width: 420px) {
  107. .title {
  108. font-size: 1.4rem;
  109. }
  110. }
  111. .details {
  112. margin: 0;
  113. line-height: 1.6;
  114. font-size: 1rem;
  115. color: var(--c-text-light);
  116. }
  117. .title + .details {
  118. padding-top: 0.25rem;
  119. }
  120. </style>