blob: be52e3cbfd602e6dc2dea77f52cc28f2e39bcceb (
plain)
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
|
package main
import ()
/*
* This file contains all the code related to turning entries into HTML pages
*/
type page struct {
pageName string
content []string
}
func (p *page) appendContent(c string) {
p.content = append(p.content, c)
}
type Renderer interface {
render(pages map[string]page) (err error)
}
func (e entry) render(pages map[string]page) (err error) {
md, err := processMarkdown(e.fullPath)
if err != nil {
return
}
p := page{pageName: e.name, content: []string{md}}
pages[e.rawName] = p
return
}
func (le logEntry) render(pages map[string]page) (err error) {
md, err := processMarkdown(le.baseEntry.fullPath)
if err != nil {
return
}
logUrl := "log"
if val, ok := pages[logUrl]; ok {
val.appendContent(md)
pages[logUrl] = val
} else {
p := page{pageName: "Log", content: []string{md}}
pages[logUrl] = p
}
return
}
func createPageMap(site *siteData, entries []Renderer) {
pages := make(map[string]page)
for _, e := range entries {
err := e.render(pages)
if err != nil {
panic(err)
}
}
// create landing page
pages[""] = page{pageName: "Home"}
site.pages = pages
}
|