summaryrefslogtreecommitdiffstats
path: root/hugolib/page.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-17 16:35:09 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-27 15:43:56 +0200
commitdf953839143c15e147d35f8908ed7f02fb62a10a (patch)
treeb28281c9d66acf35ee9796e523f64d5ee00412ed /hugolib/page.go
parenta49bf8707b7f247f1c83b8087abd02a84d2ba136 (diff)
hugolib: Speed up URL handling
Diffstat (limited to 'hugolib/page.go')
-rw-r--r--hugolib/page.go25
1 files changed, 15 insertions, 10 deletions
diff --git a/hugolib/page.go b/hugolib/page.go
index e0b97a271..cad9b398b 100644
--- a/hugolib/page.go
+++ b/hugolib/page.go
@@ -204,6 +204,8 @@ type Page struct {
// This is the PageOutput that represents the first item in outputFormats.
// Use with care, as there are potential for inifinite loops.
mainPageOutput *PageOutput
+
+ targetPathDescriptorPrototype *targetPathDescriptor
}
func (p *Page) createLayoutDescriptor() output.LayoutDescriptor {
@@ -861,23 +863,24 @@ func (p *Page) URL() string {
// Permalink returns the absolute URL to this Page.
func (p *Page) Permalink() string {
- p.initURLs()
return p.permalink
}
// RelPermalink gets a URL to the resource relative to the host.
func (p *Page) RelPermalink() string {
- p.initURLs()
return p.relPermalink
}
-func (p *Page) initURLs() {
- p.pageURLInit.Do(func() {
- rel := p.createRelativePermalink()
- p.permalink = p.s.permalink(rel)
- rel = p.s.PathSpec.PrependBasePath(rel)
- p.relPermalink = rel
- })
+func (p *Page) initURLs() error {
+ // TODO(bep) output
+ if len(p.outputFormats) == 0 {
+ p.outputFormats = p.s.defaultOutputDefinitions.ForKind(p.Kind)
+ }
+ rel := p.createRelativePermalink()
+ p.permalink = p.s.permalink(rel)
+ rel = p.s.PathSpec.PrependBasePath(rel)
+ p.relPermalink = rel
+ return nil
}
var ErrHasDraftAndPublished = errors.New("both draft and published parameters were found in page's frontmatter")
@@ -1536,7 +1539,9 @@ func (p *Page) updatePageDates() {
// so they will be evaluated again, for word count calculations etc.
func (p *Page) copy() *Page {
c := *p
- c.pageInit = &pageInit{}
+ c.pageInit = &pageInit{
+ //pageMenusInit: p.pageMenusInit,
+ }
return &c
}