~kungtotte/dtt

c9a9d48872cd478e0e15129f3435858a3b5a9082 — Thomas Landin 4 months ago c0a6811
Remove base_url config and code

I'm new at webdev stuff so I was being dumb with testing; I thought I
needed the base_url thing so links would work properly but if you test
using a local http server everything works fine with relative URLs.

So less code needed = more better.
2 files changed, 2 insertions(+), 6 deletions(-)

M src/dtt.nim
M src/tmpl.nim
M src/dtt.nim => src/dtt.nim +0 -3
@@ 102,9 102,6 @@ proc loadMetaData(path: string, mcontext: var Context) =
  # Load meta-data from config file into the supplied
  # mustache context
  let cfgdict = loadConfig(path)
  var url = cfgdict.getSectionValue("Site", "base_url")
  url.removeSuffix('/') # Modifies string in-place, so we need to do it here
  mcontext["base_url"] = url
  mcontext["charset"] = cfgdict.getSectionValue("Site", "charset")
  mcontext["language"] = cfgdict.getSectionValue("Site","language")
  mcontext["page_title"] = cfgdict.getSectionValue("Site","title")

M src/tmpl.nim => src/tmpl.nim +2 -3
@@ 3,7 3,6 @@ let
[Site]
charset = "UTF-8"
language = "en"
base_url = "http://my.domain"
title = "My Own Webpage"
license = "CC-BY-SA"
license_url = "https://creativecommons.org/licenses/by-sa/2.0/"


@@ 18,7 17,7 @@ email = "your@email.tld"
    <meta charset="{{charset}}">
    <meta charset="viewport" content="width=device-width, initial-scale=1">
    <title>{{page_title}}</title>
    <link rel="stylesheet" type="text/css" href="{{base_url}}/css/style.css">
    <link rel="stylesheet" type="text/css" href="/css/style.css">
  </head>
  <body>
  {{> header}}


@@ 38,7 37,7 @@ email = "your@email.tld"
    <header>
      <nav>
        {{#links}}
            <ul><a href="{{base_url}}/{{target}}.html">{{title}}</a></ul>
            <ul><a href="/{{target}}.html">{{title}}</a></ul>
        {{/links}}
      </nav>
    </header>