Skip to content

Commit 2796999

Browse files
committed
chore: fix error deployment any PaaS
1 parent 1a0e638 commit 2796999

File tree

305 files changed

+151
-31693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

305 files changed

+151
-31693
lines changed

app/pages/books.vue

+52-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
import type { NotionPage } from '~/type'
33
import { getThumbnail } from '~/utils/getThumbnail'
44
5-
const { data: books } = await useAsyncData('books', () =>
6-
$fetch<NotionPage[]>('https://api-mybooks.tuanductran-dev-f18.workers.dev')
7-
)
8-
95
const description =
106
'Khám phá bộ sưu tập sách được tuyển chọn kỹ lưỡng, giúp bạn mở rộng tri thức và tìm cảm hứng cho những trang sách tiếp theo. Từ những tác phẩm kinh điển đến hiện đại, hãy tìm cho mình một cuốn sách yêu thích.'
117
useSeoMeta({
@@ -16,6 +12,49 @@ useSeoMeta({
1612
ogImage: '/favicon.jpg',
1713
twitterCard: 'summary_large_image'
1814
})
15+
16+
const pageSize = ref(10)
17+
const startCursor = ref<string | null>(null)
18+
const books = ref<NotionPage[]>([])
19+
const hasMore = ref(true)
20+
const isLoading = ref(false)
21+
22+
const toast = useToast()
23+
24+
const fetchBooks = async () => {
25+
if (isLoading.value || !hasMore.value) return
26+
27+
isLoading.value = true
28+
29+
try {
30+
const data = await $fetch<{
31+
results: NotionPage[]
32+
has_more: boolean
33+
next_cursor: string | null
34+
}>('https://api-mybooks.tuanductran-dev-f18.workers.dev', {
35+
params: {
36+
page_size: pageSize.value,
37+
start_cursor: startCursor.value || undefined
38+
}
39+
})
40+
41+
if (data?.results) {
42+
books.value.push(...data.results)
43+
startCursor.value = data.next_cursor
44+
hasMore.value = data.has_more
45+
} else {
46+
hasMore.value = false
47+
}
48+
} catch (error) {
49+
console.error(error)
50+
toast.add({ title: 'Error loading data', color: 'red' })
51+
hasMore.value = false
52+
} finally {
53+
isLoading.value = false
54+
}
55+
}
56+
57+
onMounted(fetchBooks)
1958
</script>
2059

2160
<template>
@@ -41,5 +80,14 @@ useSeoMeta({
4180
</NuxtLink>
4281
</li>
4382
</ul>
83+
<div v-if="hasMore" class="mt-6 flex items-center justify-center text-sm">
84+
<UButton
85+
label="Load more"
86+
variant="outline"
87+
color="primary"
88+
:loading="isLoading"
89+
@click="fetchBooks"
90+
/>
91+
</div>
4492
</div>
4593
</template>

app/pages/notes.vue

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<script setup lang="ts">
2+
import type { NotionPage } from '~/type'
3+
import { getThumbnail } from '~/utils/getThumbnail'
4+
5+
const description =
6+
'Tổng hợp tất cả ghi chú của tôi về phát triển bản thân, kỹ năng sống, và nhiều chủ đề khác, sắp xếp theo thứ tự thời gian.'
7+
useSeoMeta({
8+
title: 'Notes | Tuan Duc Tran',
9+
description,
10+
ogTitle: 'Notes | Tuan Duc Tran',
11+
ogDescription: description,
12+
ogImage: '/favicon.jpg',
13+
twitterCard: 'summary_large_image'
14+
})
15+
16+
const pageSize = ref(10)
17+
const startCursor = ref<string | null>(null)
18+
const notes = ref<NotionPage[]>([])
19+
const hasMore = ref(true)
20+
const isLoading = ref(false)
21+
22+
const toast = useToast()
23+
24+
const fetchNotes = async () => {
25+
if (isLoading.value || !hasMore.value) return
26+
27+
isLoading.value = true
28+
29+
try {
30+
const data = await $fetch<{
31+
results: NotionPage[]
32+
has_more: boolean
33+
next_cursor: string | null
34+
}>('https://api-mynotes.tuanductran-dev-f18.workers.dev', {
35+
params: {
36+
page_size: pageSize.value,
37+
start_cursor: startCursor.value || undefined
38+
}
39+
})
40+
41+
if (data?.results) {
42+
notes.value.push(...data.results)
43+
startCursor.value = data.next_cursor
44+
hasMore.value = data.has_more
45+
} else {
46+
hasMore.value = false
47+
}
48+
} catch (error) {
49+
console.error(error)
50+
toast.add({ title: 'Error loading data', color: 'red' })
51+
hasMore.value = false
52+
} finally {
53+
isLoading.value = false
54+
}
55+
}
56+
57+
onMounted(fetchNotes)
58+
</script>
59+
60+
<template>
61+
<div>
62+
<AppHeader class="mb-8" title="Notes" :description="description" />
63+
<ul class="space-y-2">
64+
<li v-for="note in notes" :key="note.id">
65+
<NuxtLink
66+
:to="note.public_url"
67+
:title="note.title"
68+
target="_blank"
69+
external
70+
class="-m-2 flex min-w-0 items-center gap-3 rounded-lg p-2 text-sm hover:bg-gray-100 dark:hover:bg-white/10"
71+
>
72+
<UAvatar
73+
:src="getThumbnail(note.public_url)"
74+
:alt="note.title"
75+
:ui="{ rounded: 'rounded-md' }"
76+
/>
77+
<p class="truncate text-gray-700 dark:text-gray-200">
78+
{{ note.title }}
79+
</p>
80+
</NuxtLink>
81+
</li>
82+
</ul>
83+
<div v-if="hasMore" class="mt-6 flex items-center justify-center text-sm">
84+
<UButton
85+
label="Load more"
86+
variant="outline"
87+
color="primary"
88+
:loading="isLoading"
89+
@click="fetchNotes"
90+
/>
91+
</div>
92+
</div>
93+
</template>

app/pages/notes/[slug].vue

-42
This file was deleted.

app/pages/notes/index.vue

-30
This file was deleted.

content.config.ts

-11
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ export default defineContentConfig({
2121
url: z.string()
2222
})
2323
}),
24-
notes: defineCollection({
25-
type: 'page',
26-
source: 'notes/*.md',
27-
schema: z.object({
28-
title: z.string(),
29-
description: z.string(),
30-
published: z.date(),
31-
slug: z.string(),
32-
cover: z.string()
33-
})
34-
}),
3524
pages: defineCollection({
3625
type: 'page',
3726
source: 'pages/*.md',

content/notes/10-bai-hoc-tu-chu-nghia-khac-ky-giup-ban-giu-binh-tinh-va-tu-chu-trong-moi-hoan-canh.md

-114
This file was deleted.

0 commit comments

Comments
 (0)