remove CDATA wrapper

This commit is contained in:
partisan 2024-09-09 21:56:40 +02:00
parent 08774dd6f4
commit 6efb5b5d6f

10
rss.go
View file

@ -30,9 +30,6 @@ func generateAtomFeed(w http.ResponseWriter, blogs []Blog, siteURL string) {
// Ensure all image paths are absolute URLs (Idiot proofing) // Ensure all image paths are absolute URLs (Idiot proofing)
absoluteContent := strings.ReplaceAll(string(htmlContent), "src=\"/", fmt.Sprintf("src=\"%s/", siteURL)) absoluteContent := strings.ReplaceAll(string(htmlContent), "src=\"/", fmt.Sprintf("src=\"%s/", siteURL))
// Wrap HTML content in <![CDATA[]]>
cdataContent := fmt.Sprintf("<![CDATA[%s]]>", absoluteContent)
// Ensure unique and stable ID // Ensure unique and stable ID
entryID := fmt.Sprintf("%s/%s/%d", siteURL, blog.Name, entry.Number) entryID := fmt.Sprintf("%s/%s/%d", siteURL, blog.Name, entry.Number)
@ -53,7 +50,7 @@ func generateAtomFeed(w http.ResponseWriter, blogs []Blog, siteURL string) {
Author: &feeds.Author{Name: entry.Author}, Author: &feeds.Author{Name: entry.Author},
Id: entryID, Id: entryID,
Updated: entry.Date, Updated: entry.Date,
Content: cdataContent, Content: absoluteContent,
}) })
} }
} }
@ -88,9 +85,6 @@ func generateBlogAtomFeed(w http.ResponseWriter, blog Blog, siteURL string) {
// Ensure all image paths are absolute URLs (Idiot proofing) // Ensure all image paths are absolute URLs (Idiot proofing)
absoluteContent := strings.ReplaceAll(string(htmlContent), "src=\"/", fmt.Sprintf("src=\"%s/", siteURL)) absoluteContent := strings.ReplaceAll(string(htmlContent), "src=\"/", fmt.Sprintf("src=\"%s/", siteURL))
// Wrap HTML content in <![CDATA[]]>
cdataContent := fmt.Sprintf("<![CDATA[%s]]>", absoluteContent)
// Ensure unique and stable ID // Ensure unique and stable ID
entryID := fmt.Sprintf("%s/%s/%d", siteURL, blog.Name, entry.Number) entryID := fmt.Sprintf("%s/%s/%d", siteURL, blog.Name, entry.Number)
@ -111,7 +105,7 @@ func generateBlogAtomFeed(w http.ResponseWriter, blog Blog, siteURL string) {
Author: &feeds.Author{Name: entry.Author}, Author: &feeds.Author{Name: entry.Author},
Id: entryID, Id: entryID,
Updated: entry.Date, Updated: entry.Date,
Content: cdataContent, Content: absoluteContent,
}) })
} }