Skip to content

Commit

Permalink
Merge pull request #382 from tanamoe/catou/fetching
Browse files Browse the repository at this point in the history
feat: improves data fetching
  • Loading branch information
catouberos authored Nov 29, 2024
2 parents 2db7448 + e07fa89 commit 50924f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 0 additions & 2 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export default defineNuxtConfig({
},
},

ssr: false,

modules: [
"@nuxt/eslint",
"@vueuse/nuxt",
Expand Down
2 changes: 1 addition & 1 deletion pages/calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const {
status,
error,
refresh,
} = await useAsyncData(
} = await useLazyAsyncData(
() =>
$pb.collection(Collections.Books).getFullList<BooksCommon>({
filter: filter.value,
Expand Down
13 changes: 5 additions & 8 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import dayjs from "dayjs";
import { Collections } from "@/types/pb";
import type { BooksCommon } from "@/types/common";
const {
public: { ogUrl },
} = useRuntimeConfig();
const { t } = useI18n({ useScope: "global" });
const { t } = useI18n();
const { $pb } = useNuxtApp();
const now = dayjs.tz();
Expand All @@ -20,23 +17,23 @@ const { data: upcoming } = await useAsyncData(() =>
sort: "+publishDate, +publication.release.title.name, +publication.volume, +edition, +publication.defaultBook.assets_via_book.priority, +assets_via_book.priority",
expand:
"publication.release.title, publication.release.publisher, assets_via_book, publication.defaultBook.assets_via_book",
requestKey: "upcoming",
}),
);
const { data: updatedBooks } = await useAsyncData(() =>
const { data: recent } = await useAsyncData(() =>
$pb.collection(Collections.Books).getList<BooksCommon>(1, 12, {
sort: "-updated",
expand:
"publication.release.title, assets_via_book, publication.defaultBook.assets_via_book",
requestKey: "recent",
}),
);
useSeoMeta({
description: t("seo.description"),
ogTitle: "Tana.moe",
ogDescription: t("seo.description"),
ogImage: ogUrl,
ogImageAlt: "Tana.moe",
});
definePageMeta({
Expand All @@ -52,6 +49,6 @@ definePageMeta({
<AppRegisterBanner />
</UContainer>

<PageIndexRecentBooks v-if="updatedBooks" :books="updatedBooks.items" />
<PageIndexRecentBooks v-if="recent" :books="recent.items" />
</div>
</template>

0 comments on commit 50924f6

Please sign in to comment.