const slash = string(os.PathSeparator)
+ var DefaultTimer = nitro.Initalize()
+
type Site struct {
- c Config
- Config Config
++ Config Config
Pages Pages
Tmpl *template.Template
Indexes IndexList
}
func (s *Site) AbsUrlify() {
- baseWithoutTrailingSlash := strings.TrimRight(s.c.BaseUrl, "/")
++ baseWithoutTrailingSlash := strings.TrimRight(s.Config.BaseUrl, "/")
+ baseWithSlash := baseWithoutTrailingSlash + "/"
for i, _ := range s.Pages {
content := string(s.Pages[i].Content)
- content = strings.Replace(content, " src=\"/", " src=\""+s.Config.BaseUrl+"/", -1)
- content = strings.Replace(content, " src='/", " src='"+s.Config.BaseUrl+"/", -1)
- content = strings.Replace(content, " href='/", " href='"+s.Config.BaseUrl+"/", -1)
- content = strings.Replace(content, " href=\"/", " href=\""+s.Config.BaseUrl+"/", -1)
- baseWithoutTrailingSlash := strings.TrimRight(s.Config.BaseUrl, "/")
- content = strings.Replace(content, baseWithoutTrailingSlash+"//", baseWithoutTrailingSlash+"/", -1)
+ content = strings.Replace(content, " src=\"/", " src=\""+baseWithSlash, -1)
+ content = strings.Replace(content, " src='/", " src='"+baseWithSlash, -1)
+ content = strings.Replace(content, " href='/", " href='"+baseWithSlash, -1)
+ content = strings.Replace(content, " href=\"/", " href=\""+baseWithSlash, -1)
+ content = strings.Replace(content, baseWithoutTrailingSlash+"//", baseWithSlash, -1)
s.Pages[i].Content = template.HTML(content)
}
}