Skip to content

Commit

Permalink
Fix path to root (#67)
Browse files Browse the repository at this point in the history
* fix homeDirRel -> srcDirRel

* bump version (bugfix release)
  • Loading branch information
pietroppeter authored Nov 7, 2021
1 parent df345bc commit 59a7178
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/far/from/home.nim
Original file line number Diff line number Diff line change
@@ -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"] = """
<a href=".">🕷️</a> is {{here_path}} <a href="{{home_path}}">🏡</a> ({{home_path}})
<a href=".">🕷️</a> is {{path_to_here}} <a href="{{path_to_root}}">🏡</a> ({{path_to_root}})
"""
nbSave
2 changes: 1 addition & 1 deletion nimib.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.2"
version = "0.2.1"
author = "Pietro Peterlongo"
description = "nimib 🐳 - nim 👑 driven ⛵ publishing ✍"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/nimib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/nimib/themes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const header* = """
</div>
<hr>
</header>"""
const homeLink* = """<a href="{{home_path}}">🏡</a>"""
const homeLink* = """<a href="{{path_to_root}}">🏡</a>"""
const githubLink* = """<a href="{{github_remote_url}}">{{{github_logo}}}</a>"""
# github light svg adapted from: https://iconify.design/icon-sets/octicon/mark-github.html
# github dark svg taken directly from github website
Expand Down Expand Up @@ -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


Expand All @@ -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"] = "<code>" & doc.context["title"].castStr & "</code>"
if isGitAvailable() and isOnGithub():
doc.partials["header_right"] = githubLink
Expand Down
2 changes: 1 addition & 1 deletion src/nimib/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
proc srcDirRel*(doc: NbDoc): RelativeDir = doc.srcDir.relativeTo doc.thisDir

0 comments on commit 59a7178

Please sign in to comment.