~kungtotte/dtt

0a2192da70ec7ccbe1ec63e3a4e2593d8ec02827 — Thomas Landin 4 months ago 5ec9d6e
Add rough outline of blog indexing

Now the context is properly populated with data, and if you have a
matching template to go with it, you'll get a blog index going.

Right now it's very simple and requires a lot of manual work to get
going, but it's something.
1 files changed, 5 insertions(+), 5 deletions(-)

M src/dtt.nim
M src/dtt.nim => src/dtt.nim +5 -5
@@ 191,7 191,7 @@ proc findBlogPosts(directory: string, tmpldir: string): seq[Table[string, string
          rendered = blogContext.renderTemplate(f, tmpl)
        let tbl = {"id": name, "post": rendered, "date": date}.toTable
        result.add(tbl)
  sort(result, dateSort)
  sort(result, dateSort, Descending)

proc buildCmd() =
  let


@@ 221,10 221,10 @@ proc buildCmd() =
        if ext == ".md":
          let tmpl = findTemplate(fname, tmpldir)
          if blogs.len > 0:
            # TODO: Implement proper blog display here
            # Right now it just makes everything into a page and does
            # no automatic linking/indexing.
            discard
            let
              cfg_bcount = config.getSectionValue("Site", "blogs_per_page").parseInt
              bcount = min(blogs.len - 1, cfg_bcount)
            mcontext["blog_posts"] = blogs[0..bcount]
          let
            output  = mcontext.renderTemplate(condir / f, tmpl, tmpldir = tmpldir)
            outfile = savepath / fname & ".html"