summaryrefslogtreecommitdiff
path: root/internal/generator/atom
diff options
context:
space:
mode:
Diffstat (limited to 'internal/generator/atom')
-rw-r--r--internal/generator/atom/atom.go6
-rw-r--r--internal/generator/atom/atom_test.go2
2 files changed, 6 insertions, 2 deletions
diff --git a/internal/generator/atom/atom.go b/internal/generator/atom/atom.go
index f57ad0d..75f4876 100644
--- a/internal/generator/atom/atom.go
+++ b/internal/generator/atom/atom.go
@@ -9,6 +9,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"time"
"codeberg.org/snonux/snonux/internal/config"
@@ -76,8 +77,11 @@ func Generate(posts []*post.Post, cfg *config.Config) error {
func buildEntries(posts []*post.Post, baseURL string) []entry {
entries := make([]entry, 0, len(posts))
+ base := strings.TrimSuffix(baseURL, "/")
for _, p := range posts {
- entryURL := fmt.Sprintf("%s/posts/%s/", baseURL, p.ID)
+ // Link to the main HTML feed page, not /posts/<id>/ (no per-post HTML there;
+ // asset URLs in content are root-relative, e.g. posts/<id>/image.jpg).
+ entryURL := fmt.Sprintf("%s/#post-%s", base, p.ID)
entries = append(entries, entry{
Title: fmt.Sprintf("Post %s", p.ID),
Link: link{Href: entryURL, Rel: "alternate"},
diff --git a/internal/generator/atom/atom_test.go b/internal/generator/atom/atom_test.go
index bf705c3..2bfdfb7 100644
--- a/internal/generator/atom/atom_test.go
+++ b/internal/generator/atom/atom_test.go
@@ -40,7 +40,7 @@ func TestGenerate_writesAtomXML(t *testing.T) {
if !strings.Contains(s, `xmlns="http://www.w3.org/2005/Atom"`) {
t.Fatalf("missing atom xmlns: %s", s)
}
- if !strings.Contains(s, "https://example.test/posts/p1/") {
+ if !strings.Contains(s, "https://example.test/#post-p1") {
t.Fatalf("missing entry link: %s", s)
}
if !strings.Contains(s, "hello") || !strings.Contains(s, `type="html"`) {