perf: aggregate homepage data and trim frontend loading
This commit is contained in:
@@ -37,19 +37,13 @@ let apiError: string | null = null;
|
||||
const { locale, t } = getI18n(Astro);
|
||||
|
||||
try {
|
||||
const [settings, posts, rawTags, rawFriendLinks, nextCategories] = await Promise.all([
|
||||
api.getSiteSettings(),
|
||||
api.getPosts(),
|
||||
api.getTags(),
|
||||
api.getFriendLinks(),
|
||||
api.getCategories(),
|
||||
]);
|
||||
const homeData = await api.getHomePageData();
|
||||
|
||||
siteSettings = settings;
|
||||
allPosts = posts;
|
||||
tags = rawTags.map(tag => tag.name);
|
||||
friendLinks = rawFriendLinks.filter(friend => friend.status === 'approved');
|
||||
categories = nextCategories;
|
||||
siteSettings = homeData.siteSettings;
|
||||
allPosts = homeData.posts;
|
||||
tags = homeData.tags.map(tag => tag.name);
|
||||
friendLinks = homeData.friendLinks.filter(friend => friend.status === 'approved');
|
||||
categories = homeData.categories;
|
||||
|
||||
const filteredPosts = allPosts.filter(post => {
|
||||
const normalizedCategory = post.category?.trim().toLowerCase() || '';
|
||||
|
||||
Reference in New Issue
Block a user