From: spf13 Date: Tue, 15 Oct 2013 13:32:21 +0000 (-0400) Subject: Adding support for MinRead. Closed #106 X-Git-Tag: v0.9~43 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4263094d75d7546af5f091ab5b82a4b362a0f500;p=brevno-suite%2Fhugo Adding support for MinRead. Closed #106 --- diff --git a/hugolib/page.go b/hugolib/page.go index 8e05ba8f..56b60440 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -60,6 +60,7 @@ type File struct { type PageMeta struct { WordCount int FuzzyWordCount int + MinRead int } type Position struct { @@ -226,6 +227,7 @@ func ReadFrom(buf io.Reader, name string) (page *Page, err error) { 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) { diff --git a/hugolib/page_test.go b/hugolib/page_test.go index b0b844c8..01737c4f 100644 --- a/hugolib/page_test.go +++ b/hugolib/page_test.go @@ -277,6 +277,10 @@ func TestWordCount(t *testing.T) { 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) {