~kungtotte/dtt

5ec9d6e53bf0eda508923bdbf31c9f9b774423b0 — Thomas Landin 4 months ago c9a9d48
Move config loading out of loadMetadata

This way I can put non-context metadata in config.cfg without breaking
things.
1 files changed, 3 insertions(+), 3 deletions(-)

M src/dtt.nim
M src/dtt.nim => src/dtt.nim +3 -3
@@ 94,14 94,13 @@ proc cleanCmd(all: bool = false, force: bool = false) =
    stderr.writeLine(fmt"{bin}: {wd} does not exist.")
    quit(ord(DttError.DirectoryNotFound))

proc loadMetaData(path: string, mcontext: var Context) =
proc loadMetaData(cfgdict: Config, mcontext: var Context) =
  # TODO: Make dtt move backwards up the hierarchy to look for config.cfg
  # so we don't error out if someone happens to run `dtt build` inside the
  # content  directory instead of the root dtt directory.

  # Load meta-data from config file into the supplied
  # mustache context
  let cfgdict = loadConfig(path)
  mcontext["charset"] = cfgdict.getSectionValue("Site", "charset")
  mcontext["language"] = cfgdict.getSectionValue("Site","language")
  mcontext["page_title"] = cfgdict.getSectionValue("Site","title")


@@ 206,7 205,8 @@ proc buildCmd() =
  if not existsDir(outdir):
    createDir(outdir)

  loadMetaData(wd / "config.cfg", mcontext)
  let config = loadConfig(wd / "config.cfg")
  loadMetaData(config, mcontext)
  let blogs = findBlogPosts(condir, tmpldir)
  mcontext["links"] = findLinks(condir, excludes=blogs)