From 9240be6d53dd6d66249f14edea5645d8cdb9774f Mon Sep 17 00:00:00 2001 From: MacRimi Date: Tue, 27 May 2025 18:10:04 +0200 Subject: [PATCH] update RSS --- web/app/rss.xml/route.ts | 42 +++++++++++++++++++++++++------------ web/components/navbar.tsx | 13 ++++++------ web/components/rss-link.tsx | 4 ++-- 3 files changed, 37 insertions(+), 22 deletions(-) diff --git a/web/app/rss.xml/route.ts b/web/app/rss.xml/route.ts index 04905e2..51f4501 100644 --- a/web/app/rss.xml/route.ts +++ b/web/app/rss.xml/route.ts @@ -7,6 +7,7 @@ interface ChangelogEntry { date: string content: string url: string + title: string } async function parseChangelog(): Promise { @@ -20,30 +21,45 @@ async function parseChangelog(): Promise { const fileContents = fs.readFileSync(changelogPath, "utf8") const entries: ChangelogEntry[] = [] - const sections = fileContents.split(/^## /gm).filter((section) => section.trim()) + // Split by any heading (## or ###) to catch all changes, not just versions + const sections = fileContents.split(/^(##\s+.*$)/gm).filter((section) => section.trim()) - for (const section of sections) { - const lines = section.split("\n") - const headerLine = lines[0] + for (let i = 0; i < sections.length - 1; i += 2) { + const headerLine = sections[i] + const content = sections[i + 1] || "" - const versionMatch = headerLine.match(/\[([^\]]+)\]/) - const dateMatch = headerLine.match(/(\d{4}-\d{2}-\d{2})/) + // Check if it's a version header (## [version] - date) + const versionMatch = headerLine.match(/##\s+\[([^\]]+)\]\s*-\s*(\d{4}-\d{2}-\d{2})/) if (versionMatch) { const version = versionMatch[1] - const date = dateMatch ? dateMatch[1] : new Date().toISOString().split("T")[0] - const content = lines.slice(1).join("\n").trim() + const date = versionMatch[2] entries.push({ version, date, - content, - url: `${process.env.NEXT_PUBLIC_SITE_URL || "https://macrimi.github.io/ProxMenux"}/changelog#${version}`, + content: content.trim(), + url: `https://macrimi.github.io/ProxMenux/changelog#${version}`, + title: `ProxMenux ${version}`, }) + } else { + // Check for date-only headers (## 2025-05-13) + const dateMatch = headerLine.match(/##\s+(\d{4}-\d{2}-\d{2})/) + if (dateMatch) { + const date = dateMatch[1] + + entries.push({ + version: date, + date, + content: content.trim(), + url: `https://macrimi.github.io/ProxMenux/changelog#${date}`, + title: `ProxMenux Update ${date}`, + }) + } } } - return entries.slice(0, 10) + return entries.slice(0, 15) // Latest 15 entries } catch (error) { console.error("Error parsing changelog:", error) return [] @@ -52,7 +68,7 @@ async function parseChangelog(): Promise { export async function GET() { const entries = await parseChangelog() - const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://macrimi.github.io/ProxMenux" + const siteUrl = "https://macrimi.github.io/ProxMenux" const rssXml = ` @@ -70,7 +86,7 @@ export async function GET() { .map( (entry) => ` - ProxMenux ${entry.version} + ${entry.title} 500 ? "..." : ""}]]> ${entry.url} ${entry.url} diff --git a/web/components/navbar.tsx b/web/components/navbar.tsx index a0f5766..eac7443 100644 --- a/web/components/navbar.tsx +++ b/web/components/navbar.tsx @@ -44,13 +44,13 @@ export default function Navbar() { ))} - {/* RSS Feed Link */} + {/* RSS Feed Link */} RSS @@ -78,15 +78,15 @@ export default function Navbar() { {item.label} ))} - + {/* RSS Feed Link - Mobile */} setIsMenuOpen(false)} target="_blank" rel="noopener noreferrer" - title="RSS Feed del Changelog" + title="RSS Feed" > RSS @@ -97,4 +97,3 @@ export default function Navbar() { ) } - diff --git a/web/components/rss-link.tsx b/web/components/rss-link.tsx index aea30d8..34daa21 100644 --- a/web/components/rss-link.tsx +++ b/web/components/rss-link.tsx @@ -6,7 +6,7 @@ import { useState } from "react" export default function RSSLink() { const [copied, setCopied] = useState(false) - const rssUrl = `${typeof window !== "undefined" ? window.location.origin : ""}/rss.xml` + const rssUrl = "https://macrimi.github.io/ProxMenux/rss.xml" const copyToClipboard = async () => { try { @@ -43,7 +43,7 @@ export default function RSSLink() {