From 59a717863840fdd694a241945b1bba31e2acb100 Mon Sep 17 00:00:00 2001 From: Pietro Peterlongo Date: Sun, 7 Nov 2021 19:38:13 +0100 Subject: [PATCH] Fix path to root (#67) * fix homeDirRel -> srcDirRel * bump version (bugfix release) --- docs/far/from/home.nim | 6 +++--- nimib.nimble | 2 +- src/nimib.nim | 2 +- src/nimib/themes.nim | 8 ++++---- src/nimib/types.nim | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/far/from/home.nim b/docs/far/from/home.nim index 7a0db523..984b7d0f 100644 --- a/docs/far/from/home.nim +++ b/docs/far/from/home.nim @@ -1,8 +1,8 @@ import nimib, strutils nbInit -nb.context["home_path"] = nb.context["home_path"].castStr.replace("/", r"\") # for CI since I run locally on Windows and CI runs on Linux: behaviour is the same -nb.context["here_path"] = nb.context["here_path"].castStr.replace("/", r"\") # for CI since I run locally on Windows and CI runs on Linux: behaviour is the same +nb.context["path_to_root"] = nb.context["path_to_root"].castStr.replace("/", r"\") # for CI since I run locally on Windows and CI runs on Linux: behaviour is the same +nb.context["path_to_here"] = nb.context["path_to_here"].castStr.replace("/", r"\") # for CI since I run locally on Windows and CI runs on Linux: behaviour is the same nb.partials["document"] = """ -🕷️ is {{here_path}} 🏡 ({{home_path}}) +🕷️ is {{path_to_here}} 🏡 ({{path_to_root}}) """ nbSave \ No newline at end of file diff --git a/nimib.nimble b/nimib.nimble index a5164bc3..9271aeb0 100644 --- a/nimib.nimble +++ b/nimib.nimble @@ -1,6 +1,6 @@ # Package -version = "0.2" +version = "0.2.1" author = "Pietro Peterlongo" description = "nimib 🐳 - nim 👑 driven ⛵ publishing ✍" license = "MIT" diff --git a/src/nimib.nim b/src/nimib.nim index cba6fd64..7de24ad8 100644 --- a/src/nimib.nim +++ b/src/nimib.nim @@ -74,7 +74,7 @@ template nbInit*(theme = themes.useDefault, thisFileRel = "") = nb.blk = NbBlock(kind: nbkImage, code: url) else: # Relative URL - let relativeUrl = nb.context["home_path"].vString / url + let relativeUrl = nb.context["path_to_root"].vString / url nb.blk = NbBlock(kind: nbkImage, code: relativeUrl) nb.blk.output = caption diff --git a/src/nimib/themes.nim b/src/nimib/themes.nim index e7162123..b817e14b 100644 --- a/src/nimib/themes.nim +++ b/src/nimib/themes.nim @@ -70,7 +70,7 @@ const header* = """
""" -const homeLink* = """🏡""" +const homeLink* = """🏡""" const githubLink* = """{{{github_logo}}}""" # github light svg adapted from: https://iconify.design/icon-sets/octicon/mark-github.html # github dark svg taken directly from github website @@ -111,8 +111,8 @@ proc optOut*(content, keyword: string): string = "{{^" & keyword & "}}" & content & "{{/" & keyword & "}}" proc useDefault*(doc: var NbDoc) = - doc.context["home_path"] = (doc.homeDirRel).string - doc.context["here_path"] = (doc.thisFileRel).string + doc.context["path_to_root"] = (doc.srcDirRel).string + doc.context["path_to_here"] = (doc.thisFileRel).string doc.context["source"] = doc.source @@ -126,7 +126,7 @@ proc useDefault*(doc: var NbDoc) = # header doc.partials["header"] = header doc.partials["header_left"] = homeLink - doc.context["title"] = doc.context["here_path"] + doc.context["title"] = doc.context["path_to_here"] doc.partials["header_center"] = "" & doc.context["title"].castStr & "" if isGitAvailable() and isOnGithub(): doc.partials["header_right"] = githubLink diff --git a/src/nimib/types.nim b/src/nimib/types.nim index 17d6559d..5186b749 100644 --- a/src/nimib/types.nim +++ b/src/nimib/types.nim @@ -45,4 +45,4 @@ proc homeDir*(doc: NbDoc): AbsoluteDir = else: doc.cfgDir / doc.cfg.homeDir.RelativeDir proc thisFileRel*(doc: NbDoc): RelativeFile = doc.thisFile.relativeTo doc.srcDir -proc homeDirRel*(doc: NbDoc): RelativeDir = doc.homeDir.relativeTo doc.thisDir \ No newline at end of file +proc srcDirRel*(doc: NbDoc): RelativeDir = doc.srcDir.relativeTo doc.thisDir \ No newline at end of file