Skip to content

Commit

Permalink
fix: homepage feed
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Sep 14, 2024
1 parent 0e5b012 commit 1ee4901
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 8 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"isomorphic-dompurify": "2.11.0",
"js-yaml": "4.1.0",
"jsdom": "24.0.0",
"jsonfeed-to-rss": "^3.0.8",
"katex": "0.16.10",
"langchain": "0.1.37",
"lottie-react": "2.4.0",
Expand Down
121 changes: 121 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 14 additions & 8 deletions src/lib/server-helper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @ts-ignore
import jsonfeedToRSS from "jsonfeed-to-rss"

export const getQuery = (req: Request) => {
const url = new URL(req.url)
const searchParams = url.searchParams
Expand Down Expand Up @@ -66,15 +69,18 @@ export class NextServerResponse {

rss(data: any, format = "json") {
if (format === "xml") {
return new Response(data, {
status: this.#status,
headers: {
"Content-Type": "application/xml; charset=utf-8",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "public, max-age=1800",
return new Response(
typeof data === "string" ? data : jsonfeedToRSS(data),
{
status: this.#status,
headers: {
"Content-Type": "application/xml; charset=utf-8",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Origin": "*",
"Cache-Control": "public, max-age=1800",
},
},
})
)
} else {
return new Response(JSON.stringify(data), {
status: this.#status,
Expand Down

0 comments on commit 1ee4901

Please sign in to comment.