Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
fix: ogp image for published page (#17)
Browse files Browse the repository at this point in the history
* - 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
  • Loading branch information
yk-eukarya committed Jul 7, 2021
1 parent 25da0d1 commit dcb4b08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/app/public.go
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
19 changes: 16 additions & 3 deletions internal/usecase/interfaces/published.go
Expand Up @@ -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(),
Expand Down

0 comments on commit dcb4b08

Please sign in to comment.