commit
fbae4f73c6
@ -0,0 +1,30 @@ |
||||
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) |
||||
} |
@ -1,9 +1,12 @@ |
||||
package templates |
||||
|
||||
const ( |
||||
URLPostfix = "aspx" |
||||
|
||||
URLRoot = "/" |
||||
URLIndex = "/index.aspx" |
||||
URLBlog = "/blog.aspx" |
||||
URLPost = "/post.aspx" |
||||
URLSlug = "/<slug:[^/\\.]*>." + URLPostfix |
||||
URLIndex = "/index." + URLPostfix |
||||
URLBlog = "/blog." + URLPostfix |
||||
URLPost = "/post." + URLPostfix |
||||
URLJSApp = "/js-bin/app.js" |
||||
) |
||||
|
Loading…
Reference in new issue