-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.nim
54 lines (41 loc) · 1.28 KB
/
index.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import nimib, nimoji, strformat, os, strutils, animu, tables
when defined(regendoc):
import osproc
nbInit(theme=useAdventOfNim)
nbDoc.title = ":christmas_tree::crown:".emojize
nbText: """
# :christmas_tree::crown: adventofnim
my nim solutions for advent of code ([home](index.html)):""".emojize
let years = ["2022", "2021", "2020"]
type Content = Table[string, seq[string]]
var content: Content
for year in years:
content[year] = @[]
for f in walkFiles(fmt"{year}/*.html"):
let g = f.replace("\\", "/")
content[year].add g
when defined(regendoc):
let cmd = "nim r -d:release " & changeFileExt(g, "nim")
echo "exec: ", cmd
if execCmd(cmd) != 0:
echo "ERROR with: ", cmd
proc `$`(c: Content): string =
for year in years:
result &= &"* {year}\n"
for page in content[year]:
result &= &" - [{page[5 .. ^1]}]({page})\n"
nbText: $content
nbText: """
useful links:
- [search solutions by language](https://aocweb.yulrizka.com/?year=2021&day=1&language=Nim)
- [jittered scatterplot of leaderboard times](http://www.maurits.vdschee.nl/scatterplot/)
how to:
* generate README.md and index.html: `nim r index`
* regenerate also all html documents: `nim -d:regendoc r index`
"""
nbSave
#[
nbDoc.filename = "README.md"
nbDoc.render = renderMark
nbSave
]#