From dcb4b0842ee19fdf35a0859e2d28932d42d8eefc Mon Sep 17 00:00:00 2001 From: yk-eukarya <81808708+yk-eukarya@users.noreply.github.com> Date: Wed, 7 Jul 2021 08:09:57 +0300 Subject: [PATCH] fix: ogp image for published page (#17) * - use project image as fallback image if the public image does not exists * - use project data as fallback if the public data does not exists * - fix routing --- internal/app/public.go | 4 ++-- internal/usecase/interfaces/published.go | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/internal/app/public.go b/internal/app/public.go index 3f020c9b0..61840dbba 100644 --- a/internal/app/public.go +++ b/internal/app/public.go @@ -46,7 +46,7 @@ func publicAPI( }) r.GET("/published/:name", func(c echo.Context) error { - name := c.Param("string") + name := c.Param("name") if name == "" { return echo.ErrNotFound } @@ -60,7 +60,7 @@ func publicAPI( }) r.GET("/published_data/:name", func(c echo.Context) error { - name := c.Param("string") + name := c.Param("name") if name == "" { return echo.ErrNotFound } diff --git a/internal/usecase/interfaces/published.go b/internal/usecase/interfaces/published.go index 0034aede5..d0476702e 100644 --- a/internal/usecase/interfaces/published.go +++ b/internal/usecase/interfaces/published.go @@ -19,10 +19,23 @@ type ProjectPublishedMetadata struct { } func ProjectPublishedMetadataFrom(prj *project.Project) ProjectPublishedMetadata { + title := prj.PublicTitle() + description := prj.PublicDescription() + image := prj.PublicImage() + if title == "" { + title = prj.Name() + } + if description == "" { + description = prj.Description() + } + if image == "" { + image = prj.ImageURL().String() + } + return ProjectPublishedMetadata{ - Title: prj.PublicTitle(), - Description: prj.PublicDescription(), - Image: prj.PublicImage(), + Title: title, + Description: description, + Image: image, Noindex: prj.PublicNoIndex(), IsBasicAuthActive: prj.IsBasicAuthActive(), BasicAuthUsername: prj.BasicAuthUsername(),