diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-22 00:25:55 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | 1b2be5e878c0bd8c68731389e46bf1c6d3664635 (patch) | |
tree | 1174452aab6221fc940db4cd31821275a00c162f /hugolib/page_paths.go | |
parent | baa29f6534fcd324dbade7dd6c32c90547e3fa4f (diff) |
hugolib: Add OutputFormats with permalinks to Page
Diffstat (limited to 'hugolib/page_paths.go')
-rw-r--r-- | hugolib/page_paths.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/hugolib/page_paths.go b/hugolib/page_paths.go index 55d0d8cd2..00d96c05c 100644 --- a/hugolib/page_paths.go +++ b/hugolib/page_paths.go @@ -219,15 +219,23 @@ func (p *Page) createRelativePermalink() string { } // Choose the main output format. In most cases, this will be HTML. - outFormat := p.outputFormats[0] - tp, err := p.createTargetPath(outFormat) + f := p.outputFormats[0] + + return p.createRelativePermalinkForOutputFormat(f) + +} + +func (p *Page) createRelativePermalinkForOutputFormat(f output.Format) string { + tp, err := p.createTargetPath(f) if err != nil { p.s.Log.ERROR.Printf("Failed to create permalink for page %q: %s", p.FullFilePath(), err) return "" } - - tp = strings.TrimSuffix(tp, outFormat.BaseFilename()) + // For /index.json etc. we must use the full path. + if strings.HasSuffix(f.BaseFilename(), "html") { + tp = strings.TrimSuffix(tp, f.BaseFilename()) + } return p.s.PathSpec.URLizeFilename(tp) } |