fixing badlink on homepage

This commit is contained in:
spf13 2013-08-06 01:06:59 +02:00
parent 6789b6c5ce
commit 783f0d6154
2 changed files with 8 additions and 6 deletions

View file

@ -1,4 +1,4 @@
Indexes:
indexes:
tag: 'tags'
BaseUrl: 'http://localhost'
baseurl: 'http://hugo.spf13.com'
...

View file

@ -200,10 +200,12 @@ func (s *Site) ProcessShortcodes() {
func (s *Site) AbsUrlify() {
for i, _ := range s.Pages {
content := string(s.Pages[i].Content)
content = strings.Replace(content, " src=\"/", " src=\""+s.c.BaseUrl+"/", -1)
content = strings.Replace(content, " src='/", " src='"+s.c.BaseUrl+"/", -1)
content = strings.Replace(content, " href='/", " href='"+s.c.BaseUrl+"/", -1)
content = strings.Replace(content, " href=\"/", " href=\""+s.c.BaseUrl+"/", -1)
content = strings.Replace(content, " src=\"/", " src=\""+s.c.BaseUrl, -1)
content = strings.Replace(content, " src='/", " src='"+s.c.BaseUrl, -1)
content = strings.Replace(content, " href='/", " href='"+s.c.BaseUrl, -1)
content = strings.Replace(content, " href=\"/", " href=\""+s.c.BaseUrl, -1)
baseWithoutTrailingSlash := strings.TrimRight(s.c.BaseUrl, "/")
content = strings.Replace(content, baseWithoutTrailingSlash+"//", baseWithoutTrailingSlash+"/", -1)
s.Pages[i].Content = template.HTML(content)
}
}