mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
hugolib: Revise paginator alias path handling
This commit is contained in:
parent
b7ed67d425
commit
24c1770288
2 changed files with 8 additions and 22 deletions
|
@ -358,23 +358,6 @@ func GetRelativePath(path, base string) (final string, err error) {
|
||||||
return name, nil
|
return name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// PaginateAliasPath creates a path used to access the aliases in the paginator.
|
|
||||||
func (p *PathSpec) PaginateAliasPath(base string, page int) string {
|
|
||||||
paginatePath := p.paginatePath
|
|
||||||
uglify := p.uglyURLs
|
|
||||||
var pth string
|
|
||||||
if base != "" {
|
|
||||||
pth = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page))
|
|
||||||
} else {
|
|
||||||
pth = filepath.FromSlash(fmt.Sprintf("/%s/%d", paginatePath, page))
|
|
||||||
}
|
|
||||||
if uglify {
|
|
||||||
pth += ".html"
|
|
||||||
}
|
|
||||||
|
|
||||||
return pth
|
|
||||||
}
|
|
||||||
|
|
||||||
// GuessSection returns the section given a source path.
|
// GuessSection returns the section given a source path.
|
||||||
// A section is the part between the root slash and the second slash
|
// A section is the part between the root slash and the second slash
|
||||||
// or before the first slash.
|
// or before the first slash.
|
||||||
|
|
|
@ -122,12 +122,15 @@ func (s *Site) renderPaginator(p *PageOutput) error {
|
||||||
paginatePath := s.Cfg.GetString("paginatePath")
|
paginatePath := s.Cfg.GetString("paginatePath")
|
||||||
|
|
||||||
// write alias for page 1
|
// write alias for page 1
|
||||||
// TODO(bep) ml all of these n.addLang ... fix.
|
addend := fmt.Sprintf("/%s/%d", paginatePath, 1)
|
||||||
//TODO(bep) output fix
|
target, err := p.createTargetPath(p.outputFormat, addend)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
aliasPath := p.addLangPathPrefix(s.PathSpec.PaginateAliasPath(path.Join(p.sections...), 1))
|
// TODO(bep) output do better
|
||||||
link := p.Permalink()
|
link := newOutputFormat(p.Page, p.outputFormat).Permalink()
|
||||||
s.writeDestAlias(aliasPath, link, nil)
|
s.writeDestAlias(target, link, nil)
|
||||||
|
|
||||||
pagers := p.paginator.Pagers()
|
pagers := p.paginator.Pagers()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue