diff options
| author | Taqib <taqib.ibrahim@gmail.com> | 2025-07-23 15:11:10 +0100 |
|---|---|---|
| committer | Taqib <taqib.ibrahim@gmail.com> | 2025-07-23 15:11:10 +0100 |
| commit | 57243bc4b4d28e80e42ec70e3656e5a94c8407e2 (patch) | |
| tree | b0d025527b3148c05e650f3a6890780902e0e376 /apps | |
| parent | cabf86033032f0a396569cce9165cd656be791d6 (diff) | |
| download | opencut-57243bc4b4d28e80e42ec70e3656e5a94c8407e2.tar.gz | |
feat: add an rss feed
Diffstat (limited to 'apps')
| -rw-r--r-- | apps/web/package.json | 1 | ||||
| -rw-r--r-- | apps/web/src/app/metadata.ts | 32 | ||||
| -rw-r--r-- | apps/web/src/app/rss.xml/route.ts | 40 |
3 files changed, 59 insertions, 14 deletions
diff --git a/apps/web/package.json b/apps/web/package.json index c409136c..1d16576e 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -38,6 +38,7 @@ "dotenv": "^16.5.0", "drizzle-orm": "^0.44.2", "embla-carousel-react": "^8.5.1", + "feed": "^5.1.0", "framer-motion": "^11.13.1", "input-otp": "^1.4.1", "lucide-react": "^0.468.0", diff --git a/apps/web/src/app/metadata.ts b/apps/web/src/app/metadata.ts index 6f9e6023..de8cf6f0 100644 --- a/apps/web/src/app/metadata.ts +++ b/apps/web/src/app/metadata.ts @@ -1,25 +1,29 @@ import { Metadata } from "next"; -const title = "OpenCut"; -const description = - "A simple but powerful video editor that gets the job done. In your browser."; -const openGraphImageUrl = "https://opencut.app/open-graph/default.jpg"; -const twitterImageUrl = "/open-graph/default.jpg"; +export const SITE_INFO = { + title: "OpenCut", + description: + "A simple but powerful video editor that gets the job done. In your browser.", + url: "https://opencut.app", + openGraphImage: "https://opencut.app/open-graph/default.jpg", + twitterImage: "/open-graph/default.jpg", + favicon: "/favicon.ico", +}; export const baseMetaData: Metadata = { metadataBase: new URL("https://opencut.app"), - title: title, - description: description, + title: SITE_INFO.title, + description: SITE_INFO.description, openGraph: { - title: title, - description: description, + title: SITE_INFO.title, + description: SITE_INFO.description, url: "https://opencut.app", siteName: "OpenCut", locale: "en_US", type: "website", images: [ { - url: openGraphImageUrl, + url: SITE_INFO.openGraphImage, width: 1200, height: 630, alt: "OpenCut", @@ -28,10 +32,10 @@ export const baseMetaData: Metadata = { }, twitter: { card: "summary_large_image", - title: title, - description: description, + title: SITE_INFO.title, + description: SITE_INFO.description, creator: "@opencutapp", - images: [twitterImageUrl], + images: [SITE_INFO.twitterImage], }, pinterest: { richPin: false, @@ -82,7 +86,7 @@ export const baseMetaData: Metadata = { }, appleWebApp: { capable: true, - title: title, + title: SITE_INFO.title, }, manifest: "/manifest.json", other: { diff --git a/apps/web/src/app/rss.xml/route.ts b/apps/web/src/app/rss.xml/route.ts new file mode 100644 index 00000000..1567d4a7 --- /dev/null +++ b/apps/web/src/app/rss.xml/route.ts @@ -0,0 +1,40 @@ +import { Feed } from 'feed'; +import { getPosts } from '@/lib/blog-query'; +import { SITE_INFO } from '../metadata'; + +export async function GET() { + const { posts } = await getPosts(); + + const feed = new Feed({ + title: 'OpenCut Blog', + description: SITE_INFO.description, + id: `${SITE_INFO.url}`, + link: `${SITE_INFO.url}/blog/`, + language: 'en', + image: `${SITE_INFO.openGraphImage}`, + favicon: `${SITE_INFO.favicon}`, + copyright: `All rights reserved ${new Date().getFullYear()}, ${ + SITE_INFO.title + }`, + }); + + posts.forEach((article) => { + feed.addItem({ + title: article.title, + id: `${SITE_INFO.url}/blog/${article.slug}`, + link: `${SITE_INFO.url}/blog/${article.slug}`, + description: article.description, + author: article.authors.map((author) => ({ + name: author.name ?? 'OpenCut', + })), + date: new Date(article.publishedAt), + image: article.coverImage, + }); + }); + + return new Response(feed.rss2(), { + headers: { + 'Content-Type': 'text/xml', + }, + }); +}
\ No newline at end of file |
