shithub: hugo

Download patch

ref: 4263094d75d7546af5f091ab5b82a4b362a0f500
parent: be5ace1588e54c2b0081d7c8ad57795b67307cde
author: spf13 <[email protected]>
date: Tue Oct 15 05:32:21 EDT 2013

Adding support for MinRead. Closed #106

--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -60,6 +60,7 @@
 type PageMeta struct {
 	WordCount      int
 	FuzzyWordCount int
+	MinRead        int
 }
 
 type Position struct {
@@ -226,6 +227,7 @@
 func (p *Page) analyzePage() {
 	p.WordCount = TotalWords(p.Plain())
 	p.FuzzyWordCount = int((p.WordCount+100)/100) * 100
+	p.MinRead = int((p.WordCount + 212) / 213)
 }
 
 func (p *Page) permalink() (*url.URL, error) {
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -277,6 +277,10 @@
 	if p.FuzzyWordCount != 500 {
 		t.Fatalf("incorrect word count. expected %v, got %v", 500, p.WordCount)
 	}
+
+	if p.MinRead != 3 {
+		t.Fatalf("incorrect min read. expected %v, got %v", 3, p.MinRead)
+	}
 }
 
 func TestCreatePage(t *testing.T) {