index.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div class="posts">
  3. <div class="post" v-for="article in articles">
  4. <div class="post__info">
  5. <h2 class="post__title">
  6. <nuxt-link class="post__link" :to="`/posts/${article.id}`">
  7. {{ article.title }}
  8. </nuxt-link>
  9. </h2>
  10. <div class="post__brief">
  11. {{ article.briefContent }}
  12. </div>
  13. </div>
  14. <div class="post__cover" v-if="article.coverImage">
  15. <img :src="article.coverImage" :alt="article.title" />
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script setup>
  21. const { data: articles } = await useFetch('/api/articles')
  22. </script>
  23. <style lang="stylus">
  24. .post
  25. padding: 20px 0
  26. display: flex
  27. align-items: center
  28. justify-content: space-between
  29. border-bottom: 1px dashed var(--border-gray-color)
  30. &__title
  31. font-size: 16px
  32. color: #333333
  33. margin: 0 0 15px 0
  34. &__link
  35. display: block
  36. &__brief
  37. font-size: 14px
  38. line-height: 1.6
  39. color: var(--text-secondary-color)
  40. &__cover
  41. flex: 0 0 auto
  42. width: 100px
  43. margin-left: 10px
  44. line-height: 0
  45. img
  46. width: 100px
  47. max-width: 100%
  48. &__info
  49. flex: 0 1 auto
  50. </style>