mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
Fix .WordCount, .FuzzyWordCount, .ReadingTime when summary marker is set
This bug was introduced in Hugo 0.40. It is when you use the `<!--more-->` summary marker. Note that this affects the word stats only. The related `PlainWords`, `Plain`, `Content` all return correct values. Fixes #4675 Fixes #4682
This commit is contained in:
@@ -982,22 +982,33 @@ func (p *Page) ReadFrom(buf io.Reader) (int64, error) {
|
||||
}
|
||||
|
||||
func (p *Page) WordCount() int {
|
||||
p.analyzePage()
|
||||
p.initContentPlainAndMeta()
|
||||
return p.wordCount
|
||||
}
|
||||
|
||||
func (p *Page) ReadingTime() int {
|
||||
p.analyzePage()
|
||||
p.initContentPlainAndMeta()
|
||||
return p.readingTime
|
||||
}
|
||||
|
||||
func (p *Page) FuzzyWordCount() int {
|
||||
p.analyzePage()
|
||||
p.initContentPlainAndMeta()
|
||||
return p.fuzzyWordCount
|
||||
}
|
||||
|
||||
func (p *Page) analyzePage() {
|
||||
func (p *Page) initContentPlainAndMeta() {
|
||||
p.initContent()
|
||||
p.initPlain(true)
|
||||
p.initPlainWords(true)
|
||||
p.initMeta()
|
||||
}
|
||||
|
||||
func (p *Page) initContentAndMeta() {
|
||||
p.initContent()
|
||||
p.initMeta()
|
||||
}
|
||||
|
||||
func (p *Page) initMeta() {
|
||||
p.pageMetaInit.Do(func() {
|
||||
if p.isCJKLanguage {
|
||||
p.wordCount = 0
|
||||
|
Reference in New Issue
Block a user