diff --git a/app/feed/route.ts b/app/feed/route.ts index a989569..30d79fb 100644 --- a/app/feed/route.ts +++ b/app/feed/route.ts @@ -16,14 +16,6 @@ export async function GET() { const posts = await client.fetch(`*[_type == "post"] { title, description, slug, publishedAt, - mainImage { - asset -> { - _id, - url - }, - alt - }, - "categories": categories[]->title, }`); posts.forEach((item) => { diff --git a/app/sitemap.ts b/app/sitemap.ts index dd2cf1b..d3d59e4 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,9 +1,11 @@ import { MetadataRoute } from "next"; -import { getSortedPosts, Post } from "@/content/posts"; import { SITE_URL } from "@/app/consts"; +import { client } from "@/sanity/lib/client"; -export default function sitemap(): MetadataRoute.Sitemap { - const posts = getSortedPosts(); +export default async function sitemap(): Promise { + const posts = await client.fetch(`*[_type == "post"] { + slug, publishedAt, + }`); return [ { @@ -19,9 +21,9 @@ export default function sitemap(): MetadataRoute.Sitemap { priority: 0.8, }, - ...posts.map((item: Post) => ({ - url: `${SITE_URL}/posts/${item.id}`, - lastModified: item.date, + ...posts.map((item: any) => ({ + url: `${SITE_URL}/posts/${item.slug.current}`, + lastModified: new Date(item.publishedAt), changeFrequency: "daily" as any, priority: 0.75, })),