mirror of
https://github.com/gohugoio/hugo.git
synced 2025-03-25 01:31:27 +00:00
parent
be0c1bfe13
commit
bec90e0850
2 changed files with 19 additions and 3 deletions
|
@ -299,6 +299,22 @@ func GetRelativePath(path, base string) (final string, err error) {
|
||||||
return name, nil
|
return name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PaginateAliasPath(base string, page int) string {
|
||||||
|
paginatePath := viper.GetString("paginatePath")
|
||||||
|
uglify := viper.GetBool("UglyURLs")
|
||||||
|
var p string
|
||||||
|
if base != "" {
|
||||||
|
p = filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", base, paginatePath, page))
|
||||||
|
} else {
|
||||||
|
p = filepath.FromSlash(fmt.Sprintf("/%s/%d", paginatePath, page))
|
||||||
|
}
|
||||||
|
if uglify {
|
||||||
|
p += ".html"
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ func taxonomyRenderer(s *Site, taxes <-chan taxRenderInfo, results chan<- error,
|
||||||
paginatePath := viper.GetString("paginatePath")
|
paginatePath := viper.GetString("paginatePath")
|
||||||
|
|
||||||
// write alias for page 1
|
// write alias for page 1
|
||||||
s.WriteDestAlias(fmt.Sprintf("%s/%s/%d/index.html", base, paginatePath, 1), s.permalink(base))
|
s.WriteDestAlias(helpers.PaginateAliasPath(base, 1), s.permalink(base))
|
||||||
|
|
||||||
pagers := n.paginator.Pagers()
|
pagers := n.paginator.Pagers()
|
||||||
|
|
||||||
|
@ -1191,7 +1191,7 @@ func (s *Site) RenderSectionLists() error {
|
||||||
paginatePath := viper.GetString("paginatePath")
|
paginatePath := viper.GetString("paginatePath")
|
||||||
|
|
||||||
// write alias for page 1
|
// write alias for page 1
|
||||||
s.WriteDestAlias(filepath.FromSlash(fmt.Sprintf("/%s/%s/%d", section, paginatePath, 1)), s.permalink(section))
|
s.WriteDestAlias(helpers.PaginateAliasPath(section, 1), s.permalink(section))
|
||||||
|
|
||||||
pagers := n.paginator.Pagers()
|
pagers := n.paginator.Pagers()
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ func (s *Site) RenderHomePage() error {
|
||||||
paginatePath := viper.GetString("paginatePath")
|
paginatePath := viper.GetString("paginatePath")
|
||||||
|
|
||||||
// write alias for page 1
|
// write alias for page 1
|
||||||
s.WriteDestAlias(filepath.FromSlash(fmt.Sprintf("/%s/%d", paginatePath, 1)), s.permalink("/"))
|
s.WriteDestAlias(helpers.PaginateAliasPath("", 1), s.permalink("/"))
|
||||||
|
|
||||||
pagers := n.paginator.Pagers()
|
pagers := n.paginator.Pagers()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue