mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-06-28 04:06:54 +00:00
update RSS
This commit is contained in:
parent
555af7d113
commit
9240be6d53
@ -7,6 +7,7 @@ interface ChangelogEntry {
|
|||||||
date: string
|
date: string
|
||||||
content: string
|
content: string
|
||||||
url: string
|
url: string
|
||||||
|
title: string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function parseChangelog(): Promise<ChangelogEntry[]> {
|
async function parseChangelog(): Promise<ChangelogEntry[]> {
|
||||||
@ -20,30 +21,45 @@ async function parseChangelog(): Promise<ChangelogEntry[]> {
|
|||||||
const fileContents = fs.readFileSync(changelogPath, "utf8")
|
const fileContents = fs.readFileSync(changelogPath, "utf8")
|
||||||
const entries: ChangelogEntry[] = []
|
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) {
|
for (let i = 0; i < sections.length - 1; i += 2) {
|
||||||
const lines = section.split("\n")
|
const headerLine = sections[i]
|
||||||
const headerLine = lines[0]
|
const content = sections[i + 1] || ""
|
||||||
|
|
||||||
const versionMatch = headerLine.match(/\[([^\]]+)\]/)
|
// Check if it's a version header (## [version] - date)
|
||||||
const dateMatch = headerLine.match(/(\d{4}-\d{2}-\d{2})/)
|
const versionMatch = headerLine.match(/##\s+\[([^\]]+)\]\s*-\s*(\d{4}-\d{2}-\d{2})/)
|
||||||
|
|
||||||
if (versionMatch) {
|
if (versionMatch) {
|
||||||
const version = versionMatch[1]
|
const version = versionMatch[1]
|
||||||
const date = dateMatch ? dateMatch[1] : new Date().toISOString().split("T")[0]
|
const date = versionMatch[2]
|
||||||
const content = lines.slice(1).join("\n").trim()
|
|
||||||
|
|
||||||
entries.push({
|
entries.push({
|
||||||
version,
|
version,
|
||||||
date,
|
date,
|
||||||
content,
|
content: content.trim(),
|
||||||
url: `${process.env.NEXT_PUBLIC_SITE_URL || "https://macrimi.github.io/ProxMenux"}/changelog#${version}`,
|
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) {
|
} catch (error) {
|
||||||
console.error("Error parsing changelog:", error)
|
console.error("Error parsing changelog:", error)
|
||||||
return []
|
return []
|
||||||
@ -52,7 +68,7 @@ async function parseChangelog(): Promise<ChangelogEntry[]> {
|
|||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
const entries = await parseChangelog()
|
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 = `<?xml version="1.0" encoding="UTF-8"?>
|
const rssXml = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
@ -70,7 +86,7 @@ export async function GET() {
|
|||||||
.map(
|
.map(
|
||||||
(entry) => `
|
(entry) => `
|
||||||
<item>
|
<item>
|
||||||
<title>ProxMenux ${entry.version}</title>
|
<title>${entry.title}</title>
|
||||||
<description><![CDATA[${entry.content.substring(0, 500)}${entry.content.length > 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>
|
||||||
|
@ -44,13 +44,13 @@ export default function Navbar() {
|
|||||||
</Link>
|
</Link>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* RSS Feed Link */}
|
{/* RSS Feed Link */}
|
||||||
<Link
|
<Link
|
||||||
href="/rss.xml"
|
href="https://macrimi.github.io/ProxMenux/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"
|
||||||
title="RSS Feed del Changelog"
|
title="RSS Feed"
|
||||||
>
|
>
|
||||||
<Rss className="h-4 w-4" />
|
<Rss className="h-4 w-4" />
|
||||||
<span>RSS</span>
|
<span>RSS</span>
|
||||||
@ -81,12 +81,12 @@ export default function Navbar() {
|
|||||||
|
|
||||||
{/* RSS Feed Link - Mobile */}
|
{/* RSS Feed Link - Mobile */}
|
||||||
<Link
|
<Link
|
||||||
href="/rss.xml"
|
href="https://macrimi.github.io/ProxMenux/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"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
title="RSS Feed del Changelog"
|
title="RSS Feed"
|
||||||
>
|
>
|
||||||
<Rss className="h-4 w-4" />
|
<Rss className="h-4 w-4" />
|
||||||
<span>RSS</span>
|
<span>RSS</span>
|
||||||
@ -97,4 +97,3 @@ export default function Navbar() {
|
|||||||
</header>
|
</header>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 : ""}/rss.xml`
|
const rssUrl = "https://macrimi.github.io/ProxMenux/rss.xml"
|
||||||
|
|
||||||
const copyToClipboard = async () => {
|
const copyToClipboard = async () => {
|
||||||
try {
|
try {
|
||||||
@ -43,7 +43,7 @@ export default function RSSLink() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href="/rss.xml"
|
href={rssUrl}
|
||||||
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"
|
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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user