mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-12-17 09:46:05 +00:00
Update route.ts
This commit is contained in:
parent
54af9073cb
commit
d26bc56b5c
@ -13,6 +13,21 @@ interface ChangelogEntry {
|
||||
function formatContentForRSS(content: string): string {
|
||||
return (
|
||||
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
|
||||
.replace(/^### (.+)$/gm, "<h3>$1</h3>")
|
||||
// Convert ** bold ** to <strong> tags
|
||||
@ -22,12 +37,12 @@ function formatContentForRSS(content: string): string {
|
||||
const code = match.replace(/```/g, "").trim()
|
||||
return `<pre><code>${code}</code></pre>`
|
||||
})
|
||||
.replace(/`([^`]+)`/g, "<code>$1</code>")
|
||||
// Convert - bullet points to <ul><li> tags
|
||||
.replace(/^- (.+)$/gm, "<li>$1</li>")
|
||||
// Wrap consecutive <li> tags in <ul>
|
||||
.replace(/(<li>.*?<\/li>\s*)+/g, (match) => `<ul>${match}</ul>`)
|
||||
// Convert double newlines to <br><br> for paragraphs
|
||||
.replace(/\n\n/g, "<br><br>")
|
||||
.replace(/\n/g, "<br>")
|
||||
// Clean up extra spaces
|
||||
.replace(/\s+/g, " ")
|
||||
.trim()
|
||||
@ -150,4 +165,4 @@ export async function GET() {
|
||||
"Cache-Control": "public, max-age=3600, s-maxage=3600",
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user