mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Adding support for MinRead. Closed #106
This commit is contained in:
parent
be5ace1588
commit
4263094d75
2 changed files with 6 additions and 0 deletions
|
@ -60,6 +60,7 @@ type File struct {
|
||||||
type PageMeta struct {
|
type PageMeta struct {
|
||||||
WordCount int
|
WordCount int
|
||||||
FuzzyWordCount int
|
FuzzyWordCount int
|
||||||
|
MinRead int
|
||||||
}
|
}
|
||||||
|
|
||||||
type Position struct {
|
type Position struct {
|
||||||
|
@ -226,6 +227,7 @@ func ReadFrom(buf io.Reader, name string) (page *Page, err error) {
|
||||||
func (p *Page) analyzePage() {
|
func (p *Page) analyzePage() {
|
||||||
p.WordCount = TotalWords(p.Plain())
|
p.WordCount = TotalWords(p.Plain())
|
||||||
p.FuzzyWordCount = int((p.WordCount+100)/100) * 100
|
p.FuzzyWordCount = int((p.WordCount+100)/100) * 100
|
||||||
|
p.MinRead = int((p.WordCount + 212) / 213)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Page) permalink() (*url.URL, error) {
|
func (p *Page) permalink() (*url.URL, error) {
|
||||||
|
|
|
@ -277,6 +277,10 @@ func TestWordCount(t *testing.T) {
|
||||||
if p.FuzzyWordCount != 500 {
|
if p.FuzzyWordCount != 500 {
|
||||||
t.Fatalf("incorrect word count. expected %v, got %v", 500, p.WordCount)
|
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) {
|
func TestCreatePage(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue