Skip to content

Commit

Permalink
fix: logo link relativized incorrectly when --site-base provided
Browse files Browse the repository at this point in the history
  • Loading branch information
david-christiansen committed Dec 16, 2024
1 parent 29effdf commit 252003f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/verso-manual/VersoManual.lean
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ structure Config where
draft : Bool := false
/-- The URL from which to draw the logo to show, if any -/
logo : Option String := none
/-- The URL that the logo should link to, if any (default is site root) -/
logoLink : Option String := none
/-- URL for source link -/
sourceLink : Option String := none
/-- URL for issue reports -/
Expand Down Expand Up @@ -276,6 +278,7 @@ def page (toc : List Html.Toc) (path : Path) (textTitle : String) (htmlTitle con
(showNavButtons := showNavButtons)
(base := config.baseURL)
(logo := config.logo)
(logoLink := config.logoLink)
(repoLink := config.sourceLink)
(issueLink := config.issueLink)
(extraStylesheets := config.extraCss ++ state.extraCssFiles.toList.map ("/-verso-css/" ++ ·.1))
Expand Down Expand Up @@ -479,12 +482,15 @@ where
| ("--without-html-multi"::more) => opts {cfg with emitHtmlMulti := false} more
| ("--with-word-count"::file::more) => opts {cfg with wordCount := some file} more
| ("--without-word-count"::more) => opts {cfg with wordCount := none} more
| ("--site-base-url"::base::more) => opts {cfg with baseURL := some base} more
| ("--site-base-url"::base::more) => opts {cfg with baseURL := some (fixBase base)} more
| ("--draft"::more) => opts {cfg with draft := true} more
| ("--verbose"::more) => opts {cfg with verbose := true} more
| (other :: _) => throw (↑ s!"Unknown option {other}")
| [] => pure cfg

fixBase (base : String) : String :=
if base.takeRight 1 != "/" then base ++ "/" else base

go : ReaderT ExtensionImpls IO UInt32 := do
let hasError ← IO.mkRef false
let logError msg := do hasError.set true; IO.eprintln msg
Expand Down
4 changes: 4 additions & 0 deletions src/verso-manual/VersoManual/Basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def relativize (path : Path) (url : String) : String := Id.run do
#guard_msgs in
#eval Path.relativize #["a", "b", "c", "d", "e"] "/a/b/c"

/-- info: "" -/
#guard_msgs in
#eval Path.relativize #[] "/"

end Path

/--
Expand Down
2 changes: 1 addition & 1 deletion src/verso-manual/VersoManual/Html.lean
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def page
let logoHtml := {{<img src={{url}}/>}}
let logoDest :=
if let some root := logoLink then root
else relativeRoot
else "/"
{{<a href={{logoDest}} id="logo">{{logoHtml}}</a>}}
else .empty }}
{{if showNavButtons then toc.navButtons path else .empty}}
Expand Down

0 comments on commit 252003f

Please sign in to comment.