diff --git a/src/config.fsx b/src/config.fsx index 26d5a36..6b37306 100644 --- a/src/config.fsx +++ b/src/config.fsx @@ -3,16 +3,6 @@ open Config open System.IO -// let postPredicate (projectRoot: string, page: string) = -// let fileName = Path.Combine(projectRoot,page) -// let ext = Path.GetExtension page -// if ext = ".md" then -// let ctn = File.ReadAllText fileName -// page.Contains("_public") |> not -// && ctn.Contains("layout: post") -// else -// false - let docsPredicate (projectRoot: string, page: string) = let fileName = Path.Combine(projectRoot,page) let ext = Path.GetExtension page @@ -44,11 +34,8 @@ let config = { Generators = [ {Script = "less.fsx"; Trigger = OnFileExt ".less"; OutputFile = ChangeExtension "css" } {Script = "sass.fsx"; Trigger = OnFileExt ".scss"; OutputFile = ChangeExtension "css" } - // {Script = "post.fsx"; Trigger = OnFilePredicate postPredicate; OutputFile = ChangeExtension "html" } {Script = "docs.fsx"; Trigger = OnFilePredicate docsPredicate; OutputFile = ChangeExtension "html" } {Script = "staticfile.fsx"; Trigger = OnFilePredicate staticPredicate; OutputFile = SameFileName } {Script = "index.fsx"; Trigger = Once; OutputFile = NewFileName "index.html" } - {Script = "about.fsx"; Trigger = Once; OutputFile = NewFileName "about.html" } - {Script = "contact.fsx"; Trigger = Once; OutputFile = NewFileName "contact.html" } ] } diff --git a/src/docs/index.md b/src/docs/index.md new file mode 100644 index 0000000..1f1e004 --- /dev/null +++ b/src/docs/index.md @@ -0,0 +1,10 @@ +--- +layout: docs +title: Index +published: 2022-06-06 +Author: Kevin Frey +add toc: true +add sidebar: sidebars\mainSidebar.md +--- + +This is a landing page. Feel free to click around in the sidebar. \ No newline at end of file diff --git a/src/generators/index.fsx b/src/generators/index.fsx index 8c217f2..dbd0263 100644 --- a/src/generators/index.fsx +++ b/src/generators/index.fsx @@ -6,27 +6,39 @@ open Html let generate' (ctx : SiteContents) (_: string) = let docs0 = ctx.TryGetValues () |> Option.defaultValue Seq.empty - let layoutForMinimalDocsAncestor (docsLists: seq list) = - Layout.layout ctx "Home" [ - section [Class "section"] [ - div [Class "container"] [ - yield! docsLists - |> List.map (fun docs -> - div [Class "tile is-ancestor"] [ - yield! docs - ] - ) - ] - ] - ] + // let layoutForMinimalDocsAncestor (docsLists: seq list) = + // Layout.layout ctx "Home" [ + // section [Class "section"] [ + // div [Class "container"] [ + // yield! docsLists + // |> List.map (fun docs -> + // div [Class "tile is-ancestor"] [ + // yield! docs + // ] + // ) + // ] + // ] + // ] + + // // Use this for a tile based landing page + // docs0 + // |> Seq.sortByDescending (fun x -> x.published) + // |> Seq.chunkBySize 3 + // |> Seq.map (Seq.map Layout.docsMinimalLayout) + // |> Seq.toList + // |> layoutForMinimalDocsAncestor + // |> Layout.render ctx - docs0 - |> Seq.sortByDescending (fun x -> x.published) - |> Seq.chunkBySize 3 - |> Seq.map (Seq.map Layout.docsMinimalLayout) - |> Seq.toList - |> layoutForMinimalDocsAncestor - |> Layout.render ctx + let landingPage = docs0 |> Seq.tryFind(fun x -> x.title = "Index") + match landingPage with + | Some docs -> + printfn "found!" + Layout.layout ctx docs.title [ + docs |> Layout.docsLayout + ] + | None -> + failwith "Could not find index markdown file (title: 'Index') in docs folder." let generate (ctx : SiteContents) (projectRoot: string) (page: string) = - generate' ctx page \ No newline at end of file + generate' ctx page + |> Layout.render ctx \ No newline at end of file diff --git a/src/generators/layout.fsx b/src/generators/layout.fsx index 442de8d..ea62025 100644 --- a/src/generators/layout.fsx +++ b/src/generators/layout.fsx @@ -1,6 +1,5 @@ #r "../_lib/Fornax.Core.dll" #if !FORNAX -// #load "../loaders/postloader.fsx" #load "../loaders/docsloader.fsx" #load "../loaders/pageloader.fsx" #load "../loaders/globalloader.fsx" @@ -32,7 +31,6 @@ let injectWebsocketCode (webpage:string) = webpage.Insert ( (index + head.Length + 1),websocketScript) let layout (ctx : SiteContents) active bodyCnt = - let pages = ctx.TryGetValues () |> Option.defaultValue Seq.empty let siteInfo = ctx.TryGetValue () let ttl = siteInfo @@ -103,13 +101,17 @@ let render (ctx : SiteContents) cnt = let docsLayout (docs: Docsloader.Docs) = let publishedDate = docs.published.Value.ToString("yyyy-MM-dd") - custom "nfdi-body" [Class "content"; if Array.isEmpty docs.sidebar |> not then HtmlProperties.Custom("hasSidebar", "true")] [ + let sidebar = [ if Array.isEmpty docs.sidebar |> not then for sidebarEle in docs.sidebar do - custom "nfdi-sidebar-element" [HtmlProperties.Custom ("slot", "sidebar"); HtmlProperties.Custom ("isActive","true") ] [ + yield custom "nfdi-sidebar-element" [HtmlProperties.Custom ("slot", "sidebar"); HtmlProperties.Custom ("isActive","true") ] [ div [HtmlProperties.Custom ("slot", "title")] [!! sidebarEle.Title] !! sidebarEle.Content ] + else () + ] + custom "nfdi-body" [Class "content"; if Array.isEmpty docs.sidebar |> not then HtmlProperties.Custom("hasSidebar", "true")] [ + yield! sidebar h1 [Class "front-header"] [!! docs.title] i [Class "help" ] [!! $"last updated at {publishedDate}" ]