12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <template>
- <div class="w-full overflow-y-scroll flex flex-col p-2 gap-5 mb-[100px]">
- <!-- <NuxtLink to="/blog/new">
- <button class="absolute bottom-5 right-5 bg-primary hover:opacity-50 p-4 z-20 rounded-full flex items-center justify-center duration-150">
- <IPencil class="w-10 h-10" />
- </button>
- </NuxtLink> -->
- <div
- v-show="postList?.items.length === 0"
- class="w-full h-full"
- >
- <div
- v-for="i of Array.from({ length: 10 }).map((i, idx) => idx)"
- :key="i"
- :class="i === 0 ? 'mt-0 mb-4' : 'my-4'"
- class="w-full h-32 loading rounded-md opacity-30"
- />
- </div>
- <BlogPost
- v-show="postList?.items.length > 0"
- v-for="(post, idx) in postList.items"
- :key="idx"
- :avatar="post.avatar"
- :title="post.title"
- :raw_content="post.raw_content"
- :date="post.date"
- :author="post.author"
- :attachments="post.attachments"
- />
- </div>
- </template>
- <script setup lang="ts">
- import type { TPosts } from '~/types/posts'
- definePageMeta({
- name: 'Блог',
- middleware: ['user-only'],
- })
- const { $api } = useNuxtApp()
- const postList = ref<TPosts>({
- items: []
- })
- onMounted(async () => {
- postList.value = await $api.blog.getPosts()
- })
- </script>
|