ensure trailing slash on entries to avoid duplicate urls
This commit is contained in:
parent
30e54f99fb
commit
8d3bdb6f4c
|
@ -7,7 +7,7 @@
|
||||||
<div class="h-entry">
|
<div class="h-entry">
|
||||||
<hgroup>
|
<hgroup>
|
||||||
<h3>
|
<h3>
|
||||||
<a class="u-url" href="/posts/{{ .ID }}">
|
<a class="u-url" href="/posts/{{ .ID }}/">
|
||||||
{{if .Title}}
|
{{if .Title}}
|
||||||
{{ .Title }}
|
{{ .Title }}
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"owl-blogs/app"
|
"owl-blogs/app"
|
||||||
"owl-blogs/app/repository"
|
"owl-blogs/app/repository"
|
||||||
"owl-blogs/domain/model"
|
"owl-blogs/domain/model"
|
||||||
|
@ -43,6 +44,11 @@ func NewEntryHandler(
|
||||||
func (h *EntryHandler) Handle(c *fiber.Ctx) error {
|
func (h *EntryHandler) Handle(c *fiber.Ctx) error {
|
||||||
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
|
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
|
||||||
|
|
||||||
|
url := c.OriginalURL()
|
||||||
|
if len(url) == 0 || url[len(url)-1] != '/' {
|
||||||
|
return c.Redirect(url+"/", http.StatusMovedPermanently)
|
||||||
|
}
|
||||||
|
|
||||||
loggedIn := c.Locals("author") != nil
|
loggedIn := c.Locals("author") != nil
|
||||||
|
|
||||||
entryId := c.Params("post")
|
entryId := c.Params("post")
|
||||||
|
|
Loading…
Reference in New Issue