Skip to content

Commit

Permalink
Update sitemap
Browse files Browse the repository at this point in the history
Relates to #67
  • Loading branch information
ruchernchong committed Aug 19, 2024
1 parent 5c3da19 commit f9fcbb3
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import { SITE_URL } from "@/config";
import { API_URL, SITE_URL } from "@/config";
import { fetchApi } from "@/utils/fetchApi";
import type { Make } from "@/types";
import type { MetadataRoute } from "next";

const sitemap = (): MetadataRoute.Sitemap => {
// TODO: Interim solution
const FUEL_TYPE = ["petrol", "hybrid", "electric", "diesel"];

const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
const makes = await fetchApi<Make[]>(`${API_URL}/make`);

return [
{
url: SITE_URL,
lastModified: new Date(),
changeFrequency: "yearly",
priority: 1,
},
{
url: `${SITE_URL}/cars`,
lastModified: new Date(),
},
...FUEL_TYPE.map((type) => ({
url: `${SITE_URL}/cars/${type}`,
lastModified: new Date(),
})),
...makes.map((make) => ({
url: `${SITE_URL}/make/${make}`,
lastModified: new Date(),
})),
];
};

Expand Down

0 comments on commit f9fcbb3

Please sign in to comment.