diff --git a/server/app/RenderPost.go b/server/app/RenderPost.go
index 47aea44..d5f6479 100644
--- a/server/app/RenderPost.go
+++ b/server/app/RenderPost.go
@@ -10,23 +10,40 @@ import (
)
func RenderPost(ctx web.Context, id string) error {
- post := Posts[id]
- head := fmt.Sprintf(`
%s`, post.Title, strings.Join(post.Tags, ","))
- content := ""
+ var (
+ post = Posts[id]
+ title string
+ content string
+ created string
+ tags []string
+ )
- if slices.Contains(post.Tags, "article") {
+ if post != nil {
+ title = post.Title
+ content = post.Content
+ created = post.Created
+ tags = post.Tags
+ } else {
+ title = "Not found"
+ content = fmt.Sprintf("Post `%s` does not exist.", id)
+ ctx.Status(404)
+ }
+
+ head := fmt.Sprintf(`%s`, title, strings.Join(tags, ","))
+
+ if slices.Contains(tags, "article") {
content = fmt.Sprintf(
`%s`,
- post.Title,
- post.Created,
- post.Created[:len("YYYY-MM-DD")],
- markdown.Render(post.Content),
+ title,
+ created,
+ created[:len("YYYY-MM-DD")],
+ markdown.Render(content),
)
} else {
content = fmt.Sprintf(
`%s
%s`,
- post.Title,
- markdown.Render(post.Content),
+ title,
+ markdown.Render(content),
)
}
diff --git a/server/pages/Sitemap.go b/server/pages/Sitemap.go
index efbe9ac..235a50c 100644
--- a/server/pages/Sitemap.go
+++ b/server/pages/Sitemap.go
@@ -13,7 +13,6 @@ func Sitemap(ctx web.Context) error {
html := bytes.Buffer{}
html.WriteString("https://urbach.dev\n")
html.WriteString("https://urbach.dev/blog\n")
-
articles := []*app.Post{}
for _, post := range app.Posts {