diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-01-04 15:07:10 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-01-04 19:10:39 +0300 |
commit | 2b6063c3e388056597af88709ff017d15f53c962 (patch) | |
tree | a86d4dde3cd5b7df5bb5738a248a0da0c5f640fd /hugolib | |
parent | 56ab83a59712725e1ce0dd3fd516cc7c190c8478 (diff) |
Misc depreation updates
* Deprecate .Page.Path when backed by a file
* site.Permalinks
* --ignoreVendor (use --ignoreVendorPaths)
Closes #9348
Closes #9349
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/config.go | 8 | ||||
-rw-r--r-- | hugolib/content_map_page.go | 5 | ||||
-rw-r--r-- | hugolib/page.go | 6 | ||||
-rw-r--r-- | hugolib/page__meta.go | 20 | ||||
-rw-r--r-- | hugolib/site.go | 9 | ||||
-rw-r--r-- | hugolib/site_test.go | 2 | ||||
-rw-r--r-- | hugolib/testhelpers_test.go | 7 |
7 files changed, 29 insertions, 28 deletions
diff --git a/hugolib/config.go b/hugolib/config.go index e79899b94..dffecd9a3 100644 --- a/hugolib/config.go +++ b/hugolib/config.go @@ -53,7 +53,6 @@ var ErrNoConfigFile = errors.New("Unable to locate config file or config directo // LoadConfig loads Hugo configuration into a new Viper and then adds // a set of defaults. func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (config.Provider, []string, error) { - if d.Environment == "" { d.Environment = hugo.EnvironmentProduction } @@ -110,15 +109,8 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid } // Config deprecations. - // We made this a Glob pattern in Hugo 0.75, we don't need both. - if l.cfg.GetBool("ignoreVendor") { - helpers.Deprecated("--ignoreVendor", "Use --ignoreVendorPaths \"**\"", true) - l.cfg.Set("ignoreVendorPaths", "**") - } - if l.cfg.GetString("markup.defaultMarkdownHandler") == "blackfriday" { helpers.Deprecated("markup.defaultMarkdownHandler=blackfriday", "See https://gohugo.io//content-management/formats/#list-of-content-formats", false) - } // Some settings are used before we're done collecting all settings, diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 698c96cff..228564351 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -403,7 +403,7 @@ func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesM if err != nil { return true } - rp.m.resourcePath = filepath.ToSlash(strings.TrimPrefix(rp.Path(), p.File().Dir())) + rp.m.resourcePath = filepath.ToSlash(strings.TrimPrefix(rp.File().Path(), p.File().Dir())) r = rp case files.ContentClassFile: @@ -468,7 +468,6 @@ func (m *pageMap) assembleSections() error { kind := page.KindSection if s == "/" { - kind = page.KindHome } @@ -580,7 +579,7 @@ func (m *pageMap) attachPageToViews(s string, b *contentNode) { w := getParamToLower(b.p, viewName.plural+"_weight") weight, err := cast.ToIntE(w) if err != nil { - m.s.Log.Errorf("Unable to convert taxonomy weight %#v to int for %q", w, b.p.Path()) + m.s.Log.Errorf("Unable to convert taxonomy weight %#v to int for %q", w, b.p.Pathc()) // weight will equal zero, so let the flow continue } diff --git a/hugolib/page.go b/hugolib/page.go index f35865cf0..d2d962044 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -145,7 +145,7 @@ func (p *pageState) Eq(other interface{}) bool { } func (p *pageState) GetIdentity() identity.Identity { - return identity.NewPathIdentity(files.ComponentFolderContent, filepath.FromSlash(p.Path())) + return identity.NewPathIdentity(files.ComponentFolderContent, filepath.FromSlash(p.Pathc())) } func (p *pageState) GitInfo() *gitmap.GitInfo { @@ -895,8 +895,8 @@ func (p *pageState) pathOrTitle() string { return p.File().Filename() } - if p.Path() != "" { - return p.Path() + if p.Pathc() != "" { + return p.Pathc() } return p.Title() 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, }, diff --git a/hugolib/site.go b/hugolib/site.go index dce4b8d25..bde8a2199 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -689,12 +689,6 @@ func (s *SiteInfo) AllRegularPages() page.Pages { return s.s.AllRegularPages() } -func (s *SiteInfo) Permalinks() map[string]string { - // Remove in 0.61 - helpers.Deprecated(".Site.Permalinks", "", true) - return s.permalinks -} - func (s *SiteInfo) LastChange() time.Time { return s.s.lastmod } @@ -825,7 +819,7 @@ func (s siteRefLinker) logNotFound(ref, what string, p page.Page, position text. } else if p == nil { s.errorLogger.Printf("[%s] REF_NOT_FOUND: Ref %q: %s", s.s.Lang(), ref, what) } else { - s.errorLogger.Printf("[%s] REF_NOT_FOUND: Ref %q from page %q: %s", s.s.Lang(), ref, p.Path(), what) + s.errorLogger.Printf("[%s] REF_NOT_FOUND: Ref %q from page %q: %s", s.s.Lang(), ref, p.Pathc(), what) } } @@ -1402,7 +1396,6 @@ func (s *Site) getMenusFromConfig() navigation.Menus { } s.Log.Errorf("unable to process menus in site config\n") s.Log.Errorln(err) - } for _, entry := range m { diff --git a/hugolib/site_test.go b/hugolib/site_test.go index e25991164..73cea855a 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -957,7 +957,7 @@ func TestRefLinking(t *testing.T) { func checkLinkCase(site *Site, link string, currentPage page.Page, relative bool, outputFormat string, expected string, t *testing.T, i int) { t.Helper() if out, err := site.refLink(link, currentPage, relative, outputFormat); err != nil || out != expected { - t.Fatalf("[%d] Expected %q from %q to resolve to %q, got %q - error: %s", i, link, currentPage.Path(), expected, out, err) + t.Fatalf("[%d] Expected %q from %q to resolve to %q, got %q - error: %s", i, link, currentPage.Pathc(), expected, out, err) } } diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go index 72e22ed1d..105654c4f 100644 --- a/hugolib/testhelpers_test.go +++ b/hugolib/testhelpers_test.go @@ -800,7 +800,6 @@ func (s *sitesBuilder) NpmInstall() hexec.Runner { command, err := ex.New("npm", "install") s.Assert(err, qt.IsNil) return command - } func newTestHelper(cfg config.Provider, fs *hugofs.Fs, t testing.TB) testHelper { @@ -998,7 +997,7 @@ func content(c resource.ContentProvider) string { func pagesToString(pages ...page.Page) string { var paths []string for _, p := range pages { - paths = append(paths, p.Path()) + paths = append(paths, p.Pathc()) } sort.Strings(paths) return strings.Join(paths, "|") @@ -1020,7 +1019,7 @@ func dumpPages(pages ...page.Page) { fmt.Println("---------") for _, p := range pages { fmt.Printf("Kind: %s Title: %-10s RelPermalink: %-10s Path: %-10s sections: %s Lang: %s\n", - p.Kind(), p.Title(), p.RelPermalink(), p.Path(), p.SectionsPath(), p.Lang()) + p.Kind(), p.Title(), p.RelPermalink(), p.Pathc(), p.SectionsPath(), p.Lang()) } } @@ -1028,7 +1027,7 @@ func dumpSPages(pages ...*pageState) { for i, p := range pages { fmt.Printf("%d: Kind: %s Title: %-10s RelPermalink: %-10s Path: %-10s sections: %s\n", i+1, - p.Kind(), p.Title(), p.RelPermalink(), p.Path(), p.SectionsPath()) + p.Kind(), p.Title(), p.RelPermalink(), p.Pathc(), p.SectionsPath()) } } |