Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
finalize base documentation set up
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Jun 6, 2022
1 parent 6f5f415 commit c8965da
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 38 deletions.
13 changes: 0 additions & 13 deletions src/config.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" }
]
}
10 changes: 10 additions & 0 deletions src/docs/index.md
Original file line number Diff line number Diff line change
@@ -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.
54 changes: 33 additions & 21 deletions src/generators/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,39 @@ open Html
let generate' (ctx : SiteContents) (_: string) =
let docs0 = ctx.TryGetValues<Docsloader.Docs> () |> Option.defaultValue Seq.empty

let layoutForMinimalDocsAncestor (docsLists: seq<HtmlElement> 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<HtmlElement> 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
generate' ctx page
|> Layout.render ctx
10 changes: 6 additions & 4 deletions src/generators/layout.fsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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<Pageloader.Page> () |> Option.defaultValue Seq.empty
let siteInfo = ctx.TryGetValue<Globalloader.SiteInfo> ()
let ttl =
siteInfo
Expand Down Expand Up @@ -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}" ]
Expand Down

0 comments on commit c8965da

Please sign in to comment.