Commit b7c1e89

mo khan <mo@mokhan.ca>
2026-02-01 07:08:48
fix: drop the .html suffix from the compare links
1 parent 051e023
Changed files (3)
internal/generator/compare.go
@@ -149,17 +149,21 @@ func generateComparePage(base, head string, params Params) error {
 	})
 
 	for i := range commits {
-		commits[i].Href = filepath.ToSlash(filepath.Join("../commit", commits[i].Hash+".html"))
+		commits[i].Href = filepath.ToSlash(filepath.Join("../../commit", commits[i].Hash+".html"))
 	}
 
-	fileName := baseRef.DirName() + "..." + headRef.DirName() + ".html"
-	outPath := filepath.Join(params.OutputDir, "compare", fileName)
+	dirName := baseRef.DirName() + "..." + headRef.DirName()
+	outDir := filepath.Join(params.OutputDir, "compare", dirName)
+	if err := os.MkdirAll(outDir, 0o755); err != nil {
+		return err
+	}
+	outPath := filepath.Join(outDir, "index.html")
 	f, err := os.Create(outPath)
 	if err != nil {
 		return err
 	}
 
-	rootHref := "../"
+	rootHref := "../../"
 
 	err = templates.CompareTemplate.ExecuteTemplate(f, "layout.gohtml", templates.CompareParams{
 		LayoutParams: templates.LayoutParams{
internal/generator/tags.go
@@ -29,7 +29,7 @@ func GenerateTags(entries []git.Tag, params Params) error {
 		if i < len(entries)-1 {
 			base := git.NewRef(entries[i+1].Name)
 			head := git.NewRef(tag.Name)
-			tagEntries[i].CompareHref = fmt.Sprintf("compare/%s...%s.html", base.DirName(), head.DirName())
+			tagEntries[i].CompareHref = fmt.Sprintf("compare/%s...%s/", base.DirName(), head.DirName())
 		}
 	}
 
README.md
@@ -42,7 +42,7 @@ Generated paths follow GitHub repository conventions:
 | `/commits/<ref>/page-N.html` | Commit history (page N) |
 | `/branches.html` | Branches list |
 | `/tags.html` | Tags list |
-| `/compare/<base>...<head>.html` | Diff between refs |
+| `/compare/<base>...<head>/` | Diff between refs |
 
 ### Feeds & API