Update RSS

This commit is contained in:
MacRimi 2025-05-27 17:55:27 +02:00
parent f2885fc235
commit 555af7d113
3 changed files with 31 additions and 29 deletions

View File

@ -20,14 +20,12 @@ async function parseChangelog(): Promise<ChangelogEntry[]> {
const fileContents = fs.readFileSync(changelogPath, "utf8") const fileContents = fs.readFileSync(changelogPath, "utf8")
const entries: ChangelogEntry[] = [] const entries: ChangelogEntry[] = []
// Split content by versions (assuming format ## [version] - date)
const sections = fileContents.split(/^## /gm).filter((section) => section.trim()) const sections = fileContents.split(/^## /gm).filter((section) => section.trim())
for (const section of sections) { for (const section of sections) {
const lines = section.split("\n") const lines = section.split("\n")
const headerLine = lines[0] const headerLine = lines[0]
// Extract version and date from header
const versionMatch = headerLine.match(/\[([^\]]+)\]/) const versionMatch = headerLine.match(/\[([^\]]+)\]/)
const dateMatch = headerLine.match(/(\d{4}-\d{2}-\d{2})/) const dateMatch = headerLine.match(/(\d{4}-\d{2}-\d{2})/)
@ -45,7 +43,7 @@ async function parseChangelog(): Promise<ChangelogEntry[]> {
} }
} }
return entries.slice(0, 10) // Latest 10 entries return entries.slice(0, 10)
} catch (error) { } catch (error) {
console.error("Error parsing changelog:", error) console.error("Error parsing changelog:", error)
return [] return []
@ -62,17 +60,18 @@ export async function GET() {
<title>ProxMenux Changelog</title> <title>ProxMenux Changelog</title>
<description>Latest updates and changes in ProxMenux</description> <description>Latest updates and changes in ProxMenux</description>
<link>${siteUrl}/changelog</link> <link>${siteUrl}/changelog</link>
<atom:link href="${siteUrl}/api/rss" rel="self" type="application/rss+xml"/> <atom:link href="${siteUrl}/rss.xml" rel="self" type="application/rss+xml"/>
<language>en</language> <language>en-US</language>
<lastBuildDate>${new Date().toUTCString()}</lastBuildDate> <lastBuildDate>${new Date().toUTCString()}</lastBuildDate>
<generator>ProxMenux RSS Generator</generator> <generator>ProxMenux RSS Generator</generator>
<ttl>60</ttl>
${entries ${entries
.map( .map(
(entry) => ` (entry) => `
<item> <item>
<title>ProxMenux ${entry.version}</title> <title>ProxMenux ${entry.version}</title>
<description><![CDATA[${entry.content.substring(0, 500)}...]]></description> <description><![CDATA[${entry.content.substring(0, 500)}${entry.content.length > 500 ? "..." : ""}]]></description>
<link>${entry.url}</link> <link>${entry.url}</link>
<guid isPermaLink="true">${entry.url}</guid> <guid isPermaLink="true">${entry.url}</guid>
<pubDate>${new Date(entry.date).toUTCString()}</pubDate> <pubDate>${new Date(entry.date).toUTCString()}</pubDate>

View File

@ -46,7 +46,7 @@ export default function Navbar() {
{/* RSS Feed Link */} {/* RSS Feed Link */}
<Link <Link
href="/api/rss" href="/rss.xml"
className="flex items-center space-x-2 transition-colors hover:text-primary text-orange-600 hover:text-orange-700" className="flex items-center space-x-2 transition-colors hover:text-primary text-orange-600 hover:text-orange-700"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
@ -81,7 +81,7 @@ export default function Navbar() {
{/* RSS Feed Link - Mobile */} {/* RSS Feed Link - Mobile */}
<Link <Link
href="/api/rss" href="/rss.xml"
className="flex items-center space-x-2 py-2 transition-colors hover:text-primary text-orange-600 hover:text-orange-700" className="flex items-center space-x-2 py-2 transition-colors hover:text-primary text-orange-600 hover:text-orange-700"
onClick={() => setIsMenuOpen(false)} onClick={() => setIsMenuOpen(false)}
target="_blank" target="_blank"

View File

@ -6,7 +6,7 @@ import { useState } from "react"
export default function RSSLink() { export default function RSSLink() {
const [copied, setCopied] = useState(false) const [copied, setCopied] = useState(false)
const rssUrl = `${typeof window !== "undefined" ? window.location.origin : ""}/api/rss` const rssUrl = `${typeof window !== "undefined" ? window.location.origin : ""}/rss.xml`
const copyToClipboard = async () => { const copyToClipboard = async () => {
try { try {
@ -20,37 +20,40 @@ export default function RSSLink() {
return ( return (
<div className="mb-8 p-4 bg-orange-50 border border-orange-200 rounded-lg"> <div className="mb-8 p-4 bg-orange-50 border border-orange-200 rounded-lg">
<div className="flex items-center justify-between"> <div className="space-y-3">
<div className="flex-1"> <div>
<h3 className="text-lg font-semibold text-orange-900 mb-1">Stay Updated!</h3> <h3 className="text-lg font-semibold text-orange-900 mb-1">Stay Updated!</h3>
<p className="text-orange-700 text-sm mb-3"> <p className="text-orange-700 text-sm">Subscribe to our RSS feed to get notified of new changes.</p>
Subscribe to our RSS feed to get notified of new changes. Copy the URL below or click the RSS button. </div>
</p>
<div className="flex items-center gap-2 text-xs"> {/* RSS URL and buttons - Responsive layout */}
<code className="bg-orange-100 text-orange-800 px-2 py-1 rounded flex-1 min-w-0 truncate">{rssUrl}</code> <div className="space-y-2">
<div className="flex items-center gap-2">
<code className="bg-orange-100 text-orange-800 px-2 py-1 rounded text-xs flex-1 min-w-0 truncate">
{rssUrl}
</code>
<button <button
onClick={copyToClipboard} onClick={copyToClipboard}
className="flex items-center gap-1 px-2 py-1 bg-gray-600 text-white rounded hover:bg-gray-700 transition-colors whitespace-nowrap" className="flex items-center gap-1 px-2 py-1 bg-gray-600 text-white rounded hover:bg-gray-700 transition-colors text-xs whitespace-nowrap"
title="Copy RSS URL" title="Copy RSS URL"
> >
{copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />} {copied ? <Check className="h-3 w-3" /> : <Copy className="h-3 w-3" />}
{copied ? "Copied!" : "Copy"} <span className="hidden sm:inline">{copied ? "Copied!" : "Copy"}</span>
</button> </button>
</div> </div>
</div>
<Link <Link
href="/api/rss" href="/rss.xml"
className="ml-4 flex items-center space-x-2 px-4 py-2 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition-colors" className="inline-flex items-center justify-center space-x-2 px-4 py-2 bg-orange-600 text-white rounded-lg hover:bg-orange-700 transition-colors w-full sm:w-auto"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
title="Open RSS Feed" title="Open RSS Feed"
> >
<Rss className="h-4 w-4" /> <Rss className="h-4 w-4" />
<span>RSS</span> <span>Open RSS Feed</span>
</Link> </Link>
</div> </div>
</div> </div>
</div>
) )
} }