feat: change the default format of the feed to XML
This commit is contained in:
parent
dcd64efea6
commit
0c5860453b
|
|
@ -25,7 +25,7 @@ export async function GET(request: Request) {
|
|||
),
|
||||
}
|
||||
|
||||
const format = searchParams.get("format") === "xml" ? "xml" : "json"
|
||||
const format = searchParams.get("format") === "json" ? "json" : "xml"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ export async function GET(request: Request) {
|
|||
}
|
||||
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "json"
|
||||
? "json"
|
||||
: "xml"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
|
|
|
|||
|
|
@ -32,28 +32,34 @@ export const metadata: Metadata = {
|
|||
alternates: {
|
||||
types: {
|
||||
"application/rss+xml": [
|
||||
{ url: "/feed/latest?format=xml", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0&format=xml", title: "xLog Hottest" },
|
||||
{ url: "/feed/latest", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0", title: "xLog Hottest" },
|
||||
{
|
||||
url: "/feed/hottest?interval=1&format=xml",
|
||||
url: "/feed/hottest?interval=1",
|
||||
title: "xLog Hottest of the Day",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=7&format=xml",
|
||||
url: "/feed/hottest?interval=7",
|
||||
title: "xLog Hottest of the Week",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=30&format=xml",
|
||||
url: "/feed/hottest?interval=30",
|
||||
title: "xLog Hottest of the Month",
|
||||
},
|
||||
],
|
||||
"application/feed+json": [
|
||||
{ url: "/feed/latest", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0", title: "xLog Hottest" },
|
||||
{ url: "/feed/hottest?interval=1", title: "xLog Hottest of the Day" },
|
||||
{ url: "/feed/hottest?interval=7", title: "xLog Hottest of the Week" },
|
||||
{ url: "/feed/latest?format=json", title: "xLog Latest" },
|
||||
{ url: "/feed/hottest?interval=0&format=json", title: "xLog Hottest" },
|
||||
{
|
||||
url: "/feed/hottest?interval=30",
|
||||
url: "/feed/hottest?interval=1&format=json",
|
||||
title: "xLog Hottest of the Day",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=7&format=json",
|
||||
title: "xLog Hottest of the Week",
|
||||
},
|
||||
{
|
||||
url: "/feed/hottest?interval=30&format=json",
|
||||
title: "xLog Hottest of the Month",
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ export async function GET(
|
|||
}
|
||||
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "json"
|
||||
? "json"
|
||||
: "xml"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
|
|
|
|||
|
|
@ -72,9 +72,9 @@ export async function GET(
|
|||
}
|
||||
|
||||
const format =
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "xml"
|
||||
? "xml"
|
||||
: "json"
|
||||
new URLSearchParams(request.url.split("?")[1]).get("format") === "json"
|
||||
? "json"
|
||||
: "xml"
|
||||
|
||||
const res = new NextServerResponse()
|
||||
return res.status(200).rss(data, format)
|
||||
|
|
|
|||
|
|
@ -53,13 +53,13 @@ export async function generateMetadata({
|
|||
alternates: {
|
||||
types: {
|
||||
"application/rss+xml": [
|
||||
{ url: "/feed?format=xml", title },
|
||||
{ url: "/feed/comments?format=xml", title: `Comments on ${title}` },
|
||||
],
|
||||
"application/feed+json": [
|
||||
{ url: "/feed", title },
|
||||
{ url: "/feed/comments", title: `Comments on ${title}` },
|
||||
],
|
||||
"application/feed+json": [
|
||||
{ url: "/feed?format=json", title },
|
||||
{ url: "/feed/comments?format=json", title: `Comments on ${title}` },
|
||||
],
|
||||
},
|
||||
},
|
||||
icons: images,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ export function Integration() {
|
|||
url:
|
||||
getSiteLink({
|
||||
subdomain: "xlog",
|
||||
}) + "/feed?format=xml",
|
||||
}) + "/feed",
|
||||
},
|
||||
{
|
||||
name: "JSON Feed",
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ export const SiteHeaderMenu = ({
|
|||
icon: <RssIcon className="w-full h-full text-[#ee832f]" />,
|
||||
url: `${getSiteLink({
|
||||
subdomain: handle || "",
|
||||
})}/feed?format=xml`,
|
||||
})}/feed`,
|
||||
out: true,
|
||||
},
|
||||
...(hideSearch
|
||||
|
|
|
|||
|
|
@ -41,10 +41,7 @@ export default async function middleware(req: NextRequest) {
|
|||
pathname === "/atom.xml" ||
|
||||
pathname === "/feed/xml"
|
||||
) {
|
||||
return NextResponse.redirect(
|
||||
`https://${req.headers.get("host")}/feed?format=xml`,
|
||||
301,
|
||||
)
|
||||
return NextResponse.redirect(`https://${req.headers.get("host")}/feed`, 301)
|
||||
}
|
||||
|
||||
console.log(`${req.method} ${req.nextUrl.pathname}${req.nextUrl.search}`)
|
||||
|
|
|
|||
Loading…
Reference in New Issue