Skip to content

Commit

Permalink
Add option to set logo source and link in navbar component
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Mar 7, 2023
1 parent 73d0980 commit b06c815
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion client/generators/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
open Html

let generate' (ctx : SiteContents) (_: string) =
Layout.layout ctx "Home" [
Layout.layout ctx "{{SITE_TITLE}}" [
section [Class "hero is-medium has-bg-magenta"] [
div [Class "hero-body"] [
div [Class "container has-text-justified"] [
Expand Down
5 changes: 3 additions & 2 deletions client/generators/layout.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ open FsLab.Fornax
// Can be used to set the active item color in the navbar to the same color as the hero to get a bookmark effect
let getBgColorForActiveItem (siteTitle:string) =
match siteTitle with
| "Home" -> "is-active-link-magenta"
| "{{SITE_TITLE}}" -> "is-active-link-magenta"
| _ -> siteTitle


Expand Down Expand Up @@ -42,7 +42,8 @@ let layout (ctx : SiteContents) active bodyCnt =
]
body [] [
Components.Navbar(
LogoLink = (Globals.prefixUrl "images/favicon.png"),
LogoSource = (Globals.prefixUrl "images/favicon.png"),
LogoLink = "https://fslab.org",
MenuEntries = menuEntries,
SocialLinks = [
a [Class "navbar-item is-magenta"; Href "https://twitter.com/fslaborg"] [Components.Icon "fab fa-twitter"]
Expand Down
2 changes: 1 addition & 1 deletion client/globals.fsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file contains functions that can be used everywhere.
// it should be loaded as the first scriptg in a new loader or generator.

#r "nuget: FsLab.Fornax, 0.0.0"
#r "nuget: FsLab.Fornax"

// fix urls when deployed to base url (e.g. on gh pages via subdomain)
#if WATCH
Expand Down
2 changes: 1 addition & 1 deletion client/loaders/pageloader.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ type Page = {
let loader (projectRoot: string) (siteContent: SiteContents) =

// currently, only the Home page (index.fsx) is there
siteContent.Add({title = "Home"; link = "/"})
siteContent.Add({title = "{{SITE_TITLE}}"; link = "/{{SITE_TITLE}}"})

siteContent
7 changes: 4 additions & 3 deletions src/FsLab.Fornax/Components.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ type Components() =

static member DefaultHeadTags(siteTitle: string) = DefaultHeadTagsComponent.defaultHeadTags siteTitle

static member Navbar(?LogoLink: string, ?MenuEntries: HtmlElement list, ?SocialLinks: HtmlElement list) =
let logoLink = defaultArg LogoLink (TemplateConfig.PrefixUrl "/images/favicon.png")
static member Navbar(?LogoSource: string, ?LogoLink: string, ?MenuEntries: HtmlElement list, ?SocialLinks: HtmlElement list) =
let logoSource = defaultArg LogoSource (TemplateConfig.PrefixUrl "/images/favicon.png")
let logoLink = defaultArg LogoLink (TemplateConfig.PrefixUrl "/")
let menuEntries = defaultArg MenuEntries []
let socialLinks = defaultArg SocialLinks []

NavbarComponent.fslabNavbar logoLink menuEntries socialLinks
NavbarComponent.fslabNavbar logoSource logoLink menuEntries socialLinks

static member FooterIconLink(iconClass: string, text: string, link: string) =
FooterComponent.footerIconLink iconClass text link
Expand Down
6 changes: 3 additions & 3 deletions src/FsLab.Fornax/Components/Navbar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
open Html
open FsLab.Fornax

let fslabNavbar (logoLink:string) (menuEntries: HtmlElement list) (socialLinks: HtmlElement list) =
let fslabNavbar (logoSource:string) (logoLink:string) (menuEntries: HtmlElement list) (socialLinks: HtmlElement list) =
nav [Class "navbar is-fixed-top"] [
div [Class "navbar-brand"] [
a [Class "navbar-item"; Href "/"] [
img [Src logoLink; Alt "Logo"]
a [Class "navbar-item"; Href logoLink] [
img [Src logoSource; Alt "Logo"]
]
a [
Class "navbar-burger";
Expand Down

0 comments on commit b06c815

Please sign in to comment.