You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
nikita-tokarch-uk/pkg/routes/slug.go

30 lines
538 B

package routes
import (
"net/http"
routing "github.com/jackwhelpton/fasthttp-routing/v2"
"code.tokarch.uk/mainnika/nikita-tokarch-uk/pkg/content"
)
// slug renders page by its slug
func (r *Routes) slug(c *routing.Context) (err error) {
pageSlug := c.Param("slug")
if pageSlug == "" {
return routing.NewHTTPError(http.StatusNotFound)
}
page, err := r.GhostClient.GetPageBySlug(pageSlug)
if err != nil {
return
}
pageContent := content.Blog{
Meta: page.Meta,
Posts: page.Pages,
}
return c.Write(pageContent)
}