mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-20 07:13:06 +00:00
page source creation using BBP
This commit is contained in:
parent
4828fee11d
commit
77074127e0
1 changed files with 8 additions and 2 deletions
|
@ -33,6 +33,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
|
bp "github.com/spf13/hugo/bufferpool"
|
||||||
"github.com/spf13/hugo/hugofs"
|
"github.com/spf13/hugo/hugofs"
|
||||||
"github.com/spf13/hugo/source"
|
"github.com/spf13/hugo/source"
|
||||||
"github.com/spf13/hugo/tpl"
|
"github.com/spf13/hugo/tpl"
|
||||||
|
@ -688,11 +689,16 @@ func (page *Page) SaveSourceAs(path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (page *Page) saveSourceAs(path string, safe bool) error {
|
func (page *Page) saveSourceAs(path string, safe bool) error {
|
||||||
b := new(bytes.Buffer)
|
b := bp.GetBuffer()
|
||||||
|
defer bp.PutBuffer(b)
|
||||||
|
|
||||||
b.Write(page.Source.Frontmatter)
|
b.Write(page.Source.Frontmatter)
|
||||||
b.Write(page.Source.Content)
|
b.Write(page.Source.Content)
|
||||||
|
|
||||||
err := page.saveSource(b.Bytes(), path, safe)
|
bc := make([]byte, b.Len(), b.Len())
|
||||||
|
copy(bc, b.Bytes())
|
||||||
|
|
||||||
|
err := page.saveSource(bc, path, safe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue