-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpress-wesbite.js
63 lines (56 loc) · 1.53 KB
/
express-wesbite.js
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
const nav = document.createElement("nav")
const section = document.createElement("section")
const footer = document.createElement("footer")
const layout = document.querySelector(".rest")
const body = document.body
export default class Options {
constructor(navbar, body, footer, navItems, bodyContent, footerContent, ...rest) {
this.navbar = navbar
this.body = body
this.footer = footer
this.navItems = navItems
this.bodyContent = bodyContent
this.footerContent = footerContent
this.logo = rest
}
//funcions to make it work
innerNav = () => {
nav.innerHTML =
`<div><a href="index.html">${this.logo}</a></div>` +
"<ul>" +
this.navItems
.map(function (item) {
return `<li><a href="${item}"> ${item}</a></li>`
})
.join("") +
"</ul>"
}
innerFooter = () => {
footer.innerHTML =
"<ul>" +
this.footerContent
.map(function (item) {
return `<li><a href="${item}"> ${item}</a></li>`
})
.join("") +
"</ul>"
}
init = () => {
if ((this.navbar = true)) {
body.appendChild(nav)
this.innerNav()
}
if ((this.body = "centered")) {
body.appendChild(section)
section.classList.add("centered")
section.innerHTML = `<h1>${this.bodyContent[0]}</h1>` + `<p>${this.bodyContent[1]}</p>`
}
if ((this.footer = "basic")) {
body.appendChild(footer)
footer.classList.add("basic")
this.innerFooter()
}
nav.after(layout)
section.after(layout)
}
}