From 02ae938c238c9d18448d17a8ec92c0edd8c17463 Mon Sep 17 00:00:00 2001 From: Bertrand Yuan Date: Tue, 16 Dec 2025 00:12:49 +0800 Subject: feat(back-end): introduce payload Payload is the next.js Headless CMS and App Framework, I would like to pick it up and modify it as it is MIT licensed. Many features in Payload is not applicable for our project. So, I modify it so that it is light and clear. --- src/app/rss.xml/route.ts | 66 ------------------------------------------------ 1 file changed, 66 deletions(-) delete mode 100644 src/app/rss.xml/route.ts (limited to 'src/app/rss.xml/route.ts') diff --git a/src/app/rss.xml/route.ts b/src/app/rss.xml/route.ts deleted file mode 100644 index 6a3acf6..0000000 --- a/src/app/rss.xml/route.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { description, title } from '@/app/layout.config'; -import { owner } from '@/app/layout.config'; -import { baseUrl } from '@/lib/constants'; -import { getPosts } from '@/lib/source'; -import { Feed } from 'feed'; - -export const dynamic = 'force-static'; - -const escapeForXML = (str: string) => { - return str - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); -}; - -export const GET = () => { - const feed = createFeed(); - - return new Response(feed.atom1(), { - headers: { - 'Content-Type': 'application/xml', - }, - }); -}; - -function createFeed(): Feed { - const feed = new Feed({ - title, - description, - id: baseUrl.href, - language: 'en', - copyright: `All rights reserved ${new Date().getFullYear()}, ${owner}`, - image: new URL('/banner.png', baseUrl).href, - favicon: new URL('/favicon.ico', baseUrl).href, - link: baseUrl.href, - feed: new URL('/api/rss.xml', baseUrl).href, - updated: new Date(), - }); - - const posts = getPosts(); - for (const post of posts) { - feed.addItem({ - title: post.data.title, - description: post.data.description, - link: new URL(post.url, baseUrl).href, - image: { - title: post.data.title, - type: 'image/png', - url: escapeForXML( - new URL(`/og/${post.slugs.join('/')}/image.png`, baseUrl.href).href, - ), - }, - date: post.data.date, - author: [ - { - name: post.data.author, - // link: new URL('/about', baseUrl).href, - }, - ], - }); - } - - return feed; -} -- cgit v1.2.3