Skip to content

Commit

Permalink
bugfix sitemap generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin-Umali committed Jun 22, 2024
1 parent 03bb1ea commit 626cca3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
24 changes: 20 additions & 4 deletions client/api/idea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,28 @@ export const incrementCounterOfGeneratedIdea = (accessToken: string): Promise<vo
return fetchApi("/v1/counter", { method: HttpMethod.POST, accessToken });
};

export const getCommunityGeneratedProjectData = <T extends { page?: number; limit?: number; sortBy?: string; onlySlug?: boolean }>(
export const getCommunityGeneratedProjectData = async <T extends { page?: number; limit?: number; sortBy?: string; onlySlug?: boolean }>(
params: T,
): Promise<ApiResponse<T["onlySlug"] extends true ? CommunityProjectSlugData : CommunityProjectData>> => {
return fetchApi<ApiResponse<T["onlySlug"] extends true ? CommunityProjectSlugData : CommunityProjectData>>("/v1/community", {
queryParams: params,
});
try {
return await fetchApi<ApiResponse<T["onlySlug"] extends true ? CommunityProjectSlugData : CommunityProjectData>>("/v1/community", {
queryParams: params,
timeout: 60000,
});
} catch (error) {
if (params.onlySlug) {
const defaultResponse: ApiResponse<CommunityProjectSlugData> = {
data: {
projects: [{ slug: "default-slug" }],
totalCount: 1,
},
success: false,
};
return defaultResponse as ApiResponse<T["onlySlug"] extends true ? CommunityProjectSlugData : CommunityProjectData>;
} else {
throw error;
}
}
};

export const getProjectDataBySlug = (slug: string): Promise<ApiResponse<ProjectData>> => {
Expand Down
2 changes: 1 addition & 1 deletion client/api/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const checkBackEndHealthStatus = (): Promise<ApiResponse<HealthCheckData>
{
data: {
uptime: 0,
responseTime: [],
responseTime: [0, 0],
message: "Service unavailable",
timeStamp: Date.now(),
openaiStatus: {
Expand Down
9 changes: 5 additions & 4 deletions client/app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ export default async function sitemap() {
page++;
}

const projectDetailsSiteMap: MetadataRoute.Sitemap = allCommunityProjects.map((project) => ({
url: `${NEXT_PUBLIC_PROJECT_URL}/community/project-detail/${project.slug}`,
lastmod: new Date(),
}));
const projectDetailsSiteMap: MetadataRoute.Sitemap =
allCommunityProjects.map((project) => ({
url: `${NEXT_PUBLIC_PROJECT_URL}/community/project-detail/${project.slug}`,
lastmod: new Date(),
})) ?? [];

return [...baseSitemap, ...projectDetailsSiteMap];
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion client/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const nextConfig = {
return process.env.NEXT_PUBLIC_SHOW_MAINTENANCE === "true"
? [
{
source: "/((?!maintenance).*)",
source: "/((?!maintenance|status).*)",
destination: "/maintenance",
permanent: false,
},
Expand Down

0 comments on commit 626cca3

Please sign in to comment.