summaryrefslogtreecommitdiffstats
path: root/hugolib/page_paths.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_paths.go
parenta49bf8707b7f247f1c83b8087abd02a84d2ba136 (diff)
hugolib: Speed up URL handling
Diffstat (limited to 'hugolib/page_paths.go')
-rw-r--r--hugolib/page_paths.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go
index 209ae14eb..55d0d8cd2 100644
--- a/hugolib/page_paths.go
+++ b/hugolib/page_paths.go
@@ -70,9 +70,18 @@ type targetPathDescriptor struct {
// a targetPathDescriptor. This descriptor can then be used to create paths
// and URLs for this Page.
func (p *Page) createTargetPathDescriptor(t output.Format) (targetPathDescriptor, error) {
- d := targetPathDescriptor{
+ if p.targetPathDescriptorPrototype == nil {
+ panic("Must run initTargetPathDescriptor()")
+ }
+ d := *p.targetPathDescriptorPrototype
+ d.Type = t
+ return d, nil
+}
+
+func (p *Page) initTargetPathDescriptor() error {
+
+ d := &targetPathDescriptor{
PathSpec: p.s.PathSpec,
- Type: t,
Kind: p.Kind,
Sections: p.sections,
UglyURLs: p.s.Info.uglyURLs,
@@ -93,16 +102,16 @@ func (p *Page) createTargetPathDescriptor(t output.Format) (targetPathDescriptor
if override, ok := p.Site.Permalinks[p.Section()]; ok {
opath, err := override.Expand(p)
if err != nil {
- return d, err
+ return err
}
opath, _ = url.QueryUnescape(opath)
opath = filepath.FromSlash(opath)
d.ExpandedPermalink = opath
-
}
- return d, nil
+ p.targetPathDescriptorPrototype = d
+ return nil
}