Update route.ts

This commit is contained in:
MacRimi 2025-12-14 02:12:26 +01:00
parent 54af9073cb
commit d26bc56b5c

View File

@ -13,6 +13,21 @@ interface ChangelogEntry {
function formatContentForRSS(content: string): string { function formatContentForRSS(content: string): string {
return ( return (
content content
.replace(/!\[([^\]]*)\]$$([^)]+)$$/g, (match, alt, url) => {
// Convert relative URLs to absolute
let absoluteUrl = url
if (url.startsWith("/")) {
absoluteUrl = `https://proxmenux.com${url}`
} else if (url.startsWith("http://") || url.startsWith("https://")) {
// Already absolute, but replace old GitHub URLs with new domain
absoluteUrl = url.replace("https://macrimi.github.io/ProxMenux", "https://proxmenux.com")
} else {
// Relative path, make it absolute
absoluteUrl = `https://proxmenux.com/${url}`
}
return `<img src="${absoluteUrl}" alt="${alt}" style="max-width: 100%; height: auto;" />`
})
.replace(/\[([^\]]+)\]$$([^)]+)$$/g, '<a href="$2">$1</a>')
// Convert ### headers to <h3> tags // Convert ### headers to <h3> tags
.replace(/^### (.+)$/gm, "<h3>$1</h3>") .replace(/^### (.+)$/gm, "<h3>$1</h3>")
// Convert ** bold ** to <strong> tags // Convert ** bold ** to <strong> tags
@ -22,12 +37,12 @@ function formatContentForRSS(content: string): string {
const code = match.replace(/```/g, "").trim() const code = match.replace(/```/g, "").trim()
return `<pre><code>${code}</code></pre>` return `<pre><code>${code}</code></pre>`
}) })
.replace(/`([^`]+)`/g, "<code>$1</code>")
// Convert - bullet points to <ul><li> tags // Convert - bullet points to <ul><li> tags
.replace(/^- (.+)$/gm, "<li>$1</li>") .replace(/^- (.+)$/gm, "<li>$1</li>")
// Wrap consecutive <li> tags in <ul> // Wrap consecutive <li> tags in <ul>
.replace(/(<li>.*?<\/li>\s*)+/g, (match) => `<ul>${match}</ul>`) .replace(/(<li>.*?<\/li>\s*)+/g, (match) => `<ul>${match}</ul>`)
// Convert double newlines to <br><br> for paragraphs .replace(/\n/g, "<br>")
.replace(/\n\n/g, "<br><br>")
// Clean up extra spaces // Clean up extra spaces
.replace(/\s+/g, " ") .replace(/\s+/g, " ")
.trim() .trim()
@ -150,4 +165,4 @@ export async function GET() {
"Cache-Control": "public, max-age=3600, s-maxage=3600", "Cache-Control": "public, max-age=3600, s-maxage=3600",
}, },
}) })
} }