forked from blessnetwork/b7s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb7sdocs.templ
93 lines (75 loc) · 2.53 KB
/
b7sdocs.templ
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package main
import "fmt"
import "github.com/blocklessnetwork/b7s/config"
templ page(version string, configs []config.ConfigOption) {
<html>
<head>
<title>Blockless B7S Node Configuration</title>
<link rel="icon" href="/assets/favicon/favicon.ico" type="image/x-icon" sizes="16x16"/>
<link rel="stylesheet" href="/assets/css/style.css" />
</head>
<body>
<h1>Blockless B7S Node Configuration</h1>
<p class="description">
This page lists all of the configuration options supported by the b7s daemon.
It showcases the configuration structure, as accepted in a YAML config file, environment variables that can be used to set those options and, where applicable, the CLI flags and their default values.
</p>
@b7sdocs(configs)
if version != "" {
<footer>
<small>Node version: {version}</small>
</footer>
}
</body>
</html>
}
templ b7sdocs(configs []config.ConfigOption) {
<div class="cfg-list">
for _, cfg := range configs {
<div class="cfg">
@configOption(cfg)
</div>
}
</div>
}
func formatCLIDefault(def any) string {
str := fmt.Sprint(def)
if str != "" {
return str
}
return "N/A"
}
templ configOption(cfg config.ConfigOption) {
<h2 id={cfg.FullPath}>{cfg.Name} <a class="link-icon" href={ templ.URL(fmt.Sprintf("#%s", cfg.FullPath)) }><span >🔗</span></a></h2>
if cfg.Type() != "" {
<p>Type: {cfg.Type()}</p>
}
<p>Path: {cfg.FullPath}</p>
if cfg.Env != "" {
<p>Environment variable: {cfg.Env}</p>
}
if cfg.CLI.Flag != "" {
<dl>
<dt>CLI flag:</dt>
<dd>
<ul class="cli-details">
<li class="cli">Flag: <code>--{cfg.CLI.Flag}</code></li>
if cfg.CLI.Shorthand != "" {
<li class="cli">Shorthand: <code>-{cfg.CLI.Shorthand}</code></li>
}
<li class="cli">Default: {formatCLIDefault(cfg.CLI.Default)}</li>
<li class="cli">Description: {cfg.CLI.Description}</li>
</ul>
</dd>
</dl>
}
if len(cfg.Children) > 0 {
<ul>
for _, child := range cfg.Children {
<li class="child-cfg">
@configOption(child)
</li>
}
</ul>
}
}