diff --git a/pkg/appview/handlers/common.go b/pkg/appview/handlers/common.go
index 2a731a7..fafff1e 100644
--- a/pkg/appview/handlers/common.go
+++ b/pkg/appview/handlers/common.go
@@ -13,14 +13,27 @@ type PageData struct {
User *db.User // Logged-in user (nil if not logged in)
Query string // Search query from URL parameter
RegistryURL string // Base registry URL
+
+ // Open Graph meta tag fields - set by individual page handlers
+ OGTitle string // og:title content
+ OGDescription string // og:description content
+ OGImage string // og:image URL
+ OGType string // og:type (website, profile, etc.)
+ OGURL string // og:url - canonical URL for the page
}
// NewPageData creates a PageData struct with common fields populated from the request
+// Sets default OG values for the home page - individual handlers override these
func NewPageData(r *http.Request, registryURL string) PageData {
return PageData{
- User: middleware.GetUser(r),
- Query: r.URL.Query().Get("q"),
- RegistryURL: registryURL,
+ User: middleware.GetUser(r),
+ Query: r.URL.Query().Get("q"),
+ RegistryURL: registryURL,
+ OGTitle: "ATCR - Distributed Container Registry",
+ OGDescription: "Push and pull Docker images on the AT Protocol",
+ OGImage: registryURL + "/web-app-manifest-512x512.png",
+ OGType: "website",
+ OGURL: registryURL,
}
}
diff --git a/pkg/appview/handlers/repository.go b/pkg/appview/handlers/repository.go
index 2839969..6f9e1a0 100644
--- a/pkg/appview/handlers/repository.go
+++ b/pkg/appview/handlers/repository.go
@@ -206,6 +206,22 @@ func (h *RepositoryPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
}
}
+ // Build page data with OG tags for repository
+ pageData := NewPageData(r, h.RegistryURL)
+ pageData.OGTitle = owner.Handle + "/" + repository + " - ATCR"
+ pageData.OGType = "website"
+ pageData.OGURL = h.RegistryURL + "/r/" + owner.Handle + "/" + repository
+ if repo.Description != "" {
+ pageData.OGDescription = repo.Description
+ } else {
+ pageData.OGDescription = "Container image on ATCR"
+ }
+ if repo.IconURL != "" {
+ pageData.OGImage = repo.IconURL
+ } else if owner.Avatar != "" {
+ pageData.OGImage = owner.Avatar
+ }
+
data := struct {
PageData
Owner *db.User // Repository owner
@@ -217,7 +233,7 @@ func (h *RepositoryPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
IsOwner bool // Whether current user owns this repository
ReadmeHTML template.HTML
}{
- PageData: NewPageData(r, h.RegistryURL),
+ PageData: pageData,
Owner: owner,
Repository: repo,
Tags: tagsWithPlatforms,
diff --git a/pkg/appview/handlers/user.go b/pkg/appview/handlers/user.go
index 3136e42..d7f6553 100644
--- a/pkg/appview/handlers/user.go
+++ b/pkg/appview/handlers/user.go
@@ -79,13 +79,23 @@ func (h *UserPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
})
}
+ // Build page data with OG tags for user profile
+ pageData := NewPageData(r, h.RegistryURL)
+ pageData.OGTitle = viewedUser.Handle + " - ATCR"
+ pageData.OGDescription = "Container images by " + viewedUser.Handle + " on ATCR"
+ pageData.OGType = "profile"
+ pageData.OGURL = h.RegistryURL + "/u/" + viewedUser.Handle
+ if viewedUser.Avatar != "" {
+ pageData.OGImage = viewedUser.Avatar
+ }
+
data := struct {
PageData
ViewedUser *db.User // User whose page we're viewing
Repositories []db.RepoCardData
HasProfile bool
}{
- PageData: NewPageData(r, h.RegistryURL),
+ PageData: pageData,
ViewedUser: viewedUser,
Repositories: cards,
HasProfile: hasProfile,
diff --git a/pkg/appview/templates/components/head.html b/pkg/appview/templates/components/head.html
index 86ed9b2..a8da80b 100644
--- a/pkg/appview/templates/components/head.html
+++ b/pkg/appview/templates/components/head.html
@@ -3,42 +3,11 @@
- {{ if .ViewedUser }}
-
-
-
- {{ if .ViewedUser.Avatar }}
-
- {{ else }}
-
- {{ end }}
-
-
- {{ else if .Repository }}
-
-
- {{ if .Repository.Description }}
-
- {{ else }}
-
- {{ end }}
- {{ if .Repository.IconURL }}
-
- {{ else if .Owner.Avatar }}
-
- {{ else }}
-
- {{ end }}
-
-
- {{ else }}
-
-
-
-
-
-
- {{ end }}
+
+
+
+
+