diff options
author | Bjørn Erik Pedersen <[email protected]> | 2022-01-04 13:07:10 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2022-01-04 17:10:39 +0100 |
commit | 2b6063c3e388056597af88709ff017d15f53c962 (patch) | |
tree | a86d4dde3cd5b7df5bb5738a248a0da0c5f640fd /hugolib/page__meta.go | |
parent | 56ab83a59712725e1ce0dd3fd516cc7c190c8478 (diff) | |
download | hugo-2b6063c3e388056597af88709ff017d15f53c962.tar.gz hugo-2b6063c3e388056597af88709ff017d15f53c962.zip |
Misc depreation updates
* Deprecate .Page.Path when backed by a file
* site.Permalinks
* --ignoreVendor (use --ignoreVendorPaths)
Closes #9348
Closes #9349
Diffstat (limited to 'hugolib/page__meta.go')
-rw-r--r-- | hugolib/page__meta.go | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index 7bd9f6ac7..6a10b1d36 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -233,6 +233,24 @@ func (p *pageMeta) Params() maps.Params { func (p *pageMeta) Path() string { if !p.File().IsZero() { + const example = ` + {{ $path := "" }} + {{ with .File }} + {{ $path = .Path }} + {{ else }} + {{ $path = .Path }} + {{ end }} +` + helpers.Deprecated(".Path when the page is backed by a file", "We plan to use Path for a canonical source path and you probably want to check the source is a file. To get the current behaviour, you can use a construct simlar to the below:\n"+example, false) + + } + + return p.Pathc() +} + +// This is just a bridge method, use Path in templates. +func (p *pageMeta) Pathc() string { + if !p.File().IsZero() { return p.File().Path() } return p.SectionsPath() @@ -759,7 +777,7 @@ func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingCo converter.DocumentContext{ Document: newPageForRenderHook(ps), DocumentID: id, - DocumentName: p.Path(), + DocumentName: p.File().Path(), Filename: filename, ConfigOverrides: renderingConfigOverrides, }, |