Skip to content

Commit

Permalink
Add initial static site for displaying content
Browse files Browse the repository at this point in the history
Co-authored-by: NonlinearFruit <[email protected]>
  • Loading branch information
jameschensmith and NonlinearFruit committed Sep 20, 2024
1 parent 0f5959d commit 150997e
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
book
src/*.md
5 changes: 5 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[book]
authors = []
language = "en"
multilingual = false
src = "src"
113 changes: 113 additions & 0 deletions gen-docs.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
def main [] {
ls creeds/*.json
| get name
| each {
{
file: ($in | path parse)
content: (open $in)
}
}
| group-by --to-table content.Metadata.CreedFormat
| each {|it|
match $it.group {
'Canon' => { make-canons $it }
'Catechism' => { make-catechisms $it }
'HenrysCatechism' => { make-henrys-catechisms $it }
'Confession' => { make-confessions $it }
'Creed' => { make-creeds $it }
}
}
| flatten
| str join (char newline)
| prepend $"# Summary"
| save -f "docs/src/SUMMARY.md"
}

def make-creeds [it] {
$it.items
| each {|c|
$"# ($c.content.Metadata.Title)\n\n($c.content.Data.Content)"
| save -f $"docs/src/($c.file.stem).md"

$"- [($in.content.Metadata.Title)]\(./($in.file.stem).md)"
}
| prepend $"# ($it.group)"
}

def make-canons [it] {
$it.items
| each {|c|
let articles = $c.content.Data
| each {|a|
$"## ($a.Title)\n\n($a.Content)"
}
| str join (char newline)

$"# ($c.content.Metadata.Title)\n\n($articles)"
| save -f $"docs/src/($c.file.stem).md"

$"- [($in.content.Metadata.Title)]\(./($in.file.stem).md)"
}
| prepend $"# ($it.group)"
}

def make-confessions [it] {
$it.items
| each {|c|
let data = $c.content.Data
| each {|chapter|
$chapter.Sections
| each {|section|
$"### ($section.Section)\n\n($section.Content)"
}
| prepend $"## ($chapter.Chapter) ($chapter.Title)"
| str join (char newline)
}
| str join (char newline)

$"# ($c.content.Metadata.Title)\n\n($data)"
| save -f $"docs/src/($c.file.stem).md"

$"- [($in.content.Metadata.Title)]\(./($in.file.stem).md)"
}
| prepend $"# ($it.group)"
}

def make-catechisms [it] {
$it.items
| each {|c|
let articles = $c.content.Data
| each {|a|
$"## ($a.Number) ($a.Question)\n\n($a.Answer)"
}
| str join (char newline)

$"# ($c.content.Metadata.Title)\n\n($articles)"
| save -f $"docs/src/($c.file.stem).md"

$"- [($in.content.Metadata.Title)]\(./($in.file.stem).md)"
}
| prepend $"# ($it.group)"
}

def make-henrys-catechisms [it] {
$it.items
| each {|c|
let data = $c.content.Data
| each {|question|
$question.SubQuestions
| each {|subquestion|
$"### ($question.Number).($subquestion.Number) ($subquestion.Question)\n\n($subquestion.Answer)"
}
| prepend $"## ($question.Number) ($question.Question)\n\n($question.Answer)"
| str join (char newline)
}
| str join (char newline)

$"# ($c.content.Metadata.Title)\n\n($data)"
| save -f $"docs/src/($c.file.stem).md"

$"- [($in.content.Metadata.Title)]\(./($in.file.stem).md)"
}
| prepend $"# ($it.group)"
}

0 comments on commit 150997e

Please sign in to comment.