hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit bec90e085055ef96cbd6a17604cf1020c2c82f24
parent be0c1bfe132c871d765acdb9d45a0394dd99c01d
Author: bep <bjorn.erik.pedersen@gmail.com>
Date:   Sun, 10 May 2015 18:28:47 +0200

Make page 1 alias ugly

When `uglyurls = true`

Fixes #1121

Diffstat:
Mhelpers/path.go | 16++++++++++++++++
Mhugolib/site.go | 6+++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/helpers/path.go b/helpers/path.go
@@ -299,6 +299,22 @@ func GetRelativePath(path, base string) (final string, err error) {
 	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.
 // A section is the part between the root slash and the second slash
 // or before the first slash.
diff --git a/hugolib/site.go b/hugolib/site.go
@@ -1096,7 +1096,7 @@ func taxonomyRenderer(s *Site, taxes <-chan taxRenderInfo, results chan<- error,
 			paginatePath := viper.GetString("paginatePath")
 
 			// 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()
 
@@ -1191,7 +1191,7 @@ func (s *Site) RenderSectionLists() error {
 			paginatePath := viper.GetString("paginatePath")
 
 			// 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()
 
@@ -1248,7 +1248,7 @@ func (s *Site) RenderHomePage() error {
 		paginatePath := viper.GetString("paginatePath")
 
 		// 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()