mirror of
https://github.com/gohugoio/hugo.git
synced 2024-07-02 15:20:28 +00:00
parent
77c60a3440
commit
3663828f5e
|
@ -68,6 +68,7 @@ type Page struct {
|
||||||
plainWords []string
|
plainWords []string
|
||||||
plainRuneCount int
|
plainRuneCount int
|
||||||
plainInit sync.Once
|
plainInit sync.Once
|
||||||
|
plainSecondaryInit sync.Once
|
||||||
renderingConfig *helpers.Blackfriday
|
renderingConfig *helpers.Blackfriday
|
||||||
renderingConfigInit sync.Once
|
renderingConfigInit sync.Once
|
||||||
PageMeta
|
PageMeta
|
||||||
|
@ -111,7 +112,7 @@ func (p *Page) PlainWords() []string {
|
||||||
|
|
||||||
// RuneCount returns the rune count, excluding any whitespace, of the plain content.
|
// RuneCount returns the rune count, excluding any whitespace, of the plain content.
|
||||||
func (p *Page) RuneCount() int {
|
func (p *Page) RuneCount() int {
|
||||||
p.initPlain()
|
p.initPlainSecondary()
|
||||||
return p.plainRuneCount
|
return p.plainRuneCount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +120,13 @@ func (p *Page) initPlain() {
|
||||||
p.plainInit.Do(func() {
|
p.plainInit.Do(func() {
|
||||||
p.plain = helpers.StripHTML(string(p.Content))
|
p.plain = helpers.StripHTML(string(p.Content))
|
||||||
p.plainWords = strings.Fields(p.plain)
|
p.plainWords = strings.Fields(p.plain)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Page) initPlainSecondary() {
|
||||||
|
p.plainSecondaryInit.Do(func() {
|
||||||
|
p.initPlain()
|
||||||
runeCount := 0
|
runeCount := 0
|
||||||
for _, r := range p.plain {
|
for _, r := range p.plain {
|
||||||
if !helpers.IsWhitespace(r) {
|
if !helpers.IsWhitespace(r) {
|
||||||
|
|
Loading…
Reference in a new issue