-
Notifications
You must be signed in to change notification settings - Fork 2
/
navbar.lua
57 lines (53 loc) · 1.39 KB
/
navbar.lua
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
local h = require "html"
local menu = {
{
href = "/",
text = "Home",
},
{
href = "forms.lua",
text = "Forms"
},
{
href = "dump-headers",
text = "Dump headers"
},
{
href = "files",
text = "Files"
},
{
href = "payload",
text = "Payload test"
}
}
local function genmenu()
local out = {}
for _, el in ipairs(menu) do
table.insert(out, h.li({ class = "nav-item" },
h.a({ class = "nav-link active", ["aria-current"] = "page", href = el.href }, el.text)
))
end
return table.concat(out)
end
local head = h.nav({ class = "navbar navbar-expand-lg bg-body-tertiary" },
h.div({ class = "container-fluid" },
h.a({ class = "navbar-brand", href = "index" }, "Navbar"),
h.button(
{
class = "navbar-toggler",
type = "button",
["data-bs-toggle"] = "collapse",
["data-bs-target"] = "#navbarNav",
["aria-controls"] = "navbarNav",
["aria-expanded"] = "false",
["aria-label"] = "Toggle navigation"
},
h.span { class = "navbar-toggler-icon" }
),
h.div({ class = "collapse navbar-collapse", id = "navbarNav" },
h.ul({ class = "navbar-nav" }, genmenu())
)
)
)
return head