feat: add "enclosure" and "author" attributes for the RSS feed

This commit is contained in:
Dorian Niemiec 2024-09-08 12:31:47 +02:00
parent ae6cc2ff44
commit 489dbaaf63

View file

@ -1,6 +1,6 @@
import { NextResponse } from "next/server";
import RSS from "rss";
import { client } from "@/lib/sanity";
import { client, urlFor } from "@/lib/sanity";
import { toHTML } from "@portabletext/to-html";
export const dynamic = "force-static";
@ -37,10 +37,13 @@ export async function GET() {
title: post.title,
description: toHTML(post.content),
url: `${SITE_URL}/blog/${post.slug}`,
date: new Date(post._createdAt).toUTCString()
// uncomment this if u want to
// enclosure: { url: urlFor(post.titleImage).url() },
// author: "SVR.JS",
date: new Date(post._createdAt).toUTCString(),
enclosure: {
url: post.titleImage
? urlFor(post.titleImage).url()
: `${SITE_URL}/blog-missing.png`
},
author: "SVR.JS"
});
});