~kungtotte/dtt

f7dd054d3641384d1fe390f3f772fd3c505a71cb — Thomas Landin 2 months ago 0a2192d
Find URL targets for blog posts

This way the blog title can link to the actual blog html page so you can
open just one post and read only that.
1 files changed, 4 insertions(+), 0 deletions(-)

M src/dtt.nim
M src/dtt.nim => src/dtt.nim +4 -0
@@ 185,8 185,12 @@ proc findBlogPosts(directory: string, tmpldir: string): seq[Table[string, string
          date = getBlogDate(f, (year, month, day))
          tmpl = findTemplate(name, tmpldir, isBlog)
        var blogContext = newContext(searchDirs = @[tmpldir])
        let
          subdir = if dir != directory: lastPathPart(dir) else: ""
          target = if subdir != "": subdir & "/" & name & ".html" else: name & ".html"
        blogContext["slug"] = getSlug(name, year > 0)
        blogContext["date"] = date
        blogContext["blog_link"] = target
        let
          rendered = blogContext.renderTemplate(f, tmpl)
        let tbl = {"id": name, "post": rendered, "date": date}.toTable