mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
permalink now respects pretty urls
This commit is contained in:
parent
d5f5543061
commit
92c31bbe10
2 changed files with 14 additions and 4 deletions
|
@ -228,13 +228,22 @@ func splitPageContent(data []byte, start string, end string) ([]string, []string
|
|||
|
||||
func (p *Page) Permalink() template.HTML {
|
||||
if len(strings.TrimSpace(p.Slug)) > 0 {
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+p.Slug))
|
||||
if p.Site.Config.UglyUrls {
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+p.Slug+"."+p.Extension))
|
||||
} else {
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+p.Slug))
|
||||
}
|
||||
} else if len(strings.TrimSpace(p.Url)) > 2 {
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Url)))
|
||||
} else {
|
||||
_, t := filepath.Split(p.FileName)
|
||||
x := replaceExtension(strings.TrimSpace(t), p.Extension)
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+x))
|
||||
if p.Site.Config.UglyUrls {
|
||||
x := replaceExtension(strings.TrimSpace(t), p.Extension)
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+x))
|
||||
} else {
|
||||
file, _ := fileExt(strings.TrimSpace(t))
|
||||
return template.HTML(MakePermalink(string(p.Site.BaseUrl), strings.TrimSpace(p.Section)+"/"+file))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ type SiteInfo struct {
|
|||
Recent *Pages
|
||||
LastChange time.Time
|
||||
Title string
|
||||
Config *Config
|
||||
}
|
||||
|
||||
func (s *Site) getFromIndex(kind string, name string) Pages {
|
||||
|
@ -166,7 +167,7 @@ func (s *Site) initialize() {
|
|||
|
||||
filepath.Walk(s.c.GetAbsPath(s.c.SourceDir), walker)
|
||||
|
||||
s.Info = SiteInfo{BaseUrl: template.URL(s.c.BaseUrl), Title: s.c.Title}
|
||||
s.Info = SiteInfo{BaseUrl: template.URL(s.c.BaseUrl), Title: s.c.Title, Config: &s.c}
|
||||
|
||||
s.Shortcodes = make(map[string]ShortcodeFunc)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue