mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Misc depreation updates
* Deprecate .Page.Path when backed by a file * site.Permalinks * --ignoreVendor (use --ignoreVendorPaths) Closes #9348 Closes #9349
This commit is contained in:
parent
56ab83a597
commit
2b6063c3e3
19 changed files with 52 additions and 58 deletions
|
@ -131,8 +131,7 @@ type hugoCmd struct {
|
||||||
|
|
||||||
var _ cmder = (*nilCommand)(nil)
|
var _ cmder = (*nilCommand)(nil)
|
||||||
|
|
||||||
type nilCommand struct {
|
type nilCommand struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (c *nilCommand) getCommand() *cobra.Command {
|
func (c *nilCommand) getCommand() *cobra.Command {
|
||||||
return nil
|
return nil
|
||||||
|
@ -281,7 +280,6 @@ func (cc *hugoBuilderCommon) handleCommonBuilderFlags(cmd *cobra.Command) {
|
||||||
cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
|
cmd.PersistentFlags().SetAnnotation("source", cobra.BashCompSubdirsInDir, []string{})
|
||||||
cmd.PersistentFlags().StringVarP(&cc.environment, "environment", "e", "", "build environment")
|
cmd.PersistentFlags().StringVarP(&cc.environment, "environment", "e", "", "build environment")
|
||||||
cmd.PersistentFlags().StringP("themesDir", "", "", "filesystem path to themes directory")
|
cmd.PersistentFlags().StringP("themesDir", "", "", "filesystem path to themes directory")
|
||||||
cmd.PersistentFlags().BoolP("ignoreVendor", "", false, "ignores any _vendor directory")
|
|
||||||
cmd.PersistentFlags().StringP("ignoreVendorPaths", "", "", "ignores any _vendor for module paths matching the given Glob pattern")
|
cmd.PersistentFlags().StringP("ignoreVendorPaths", "", "", "ignores any _vendor for module paths matching the given Glob pattern")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -162,16 +162,6 @@ func TestFlags(t *testing.T) {
|
||||||
args []string
|
args []string
|
||||||
check func(c *qt.C, cmd *serverCmd)
|
check func(c *qt.C, cmd *serverCmd)
|
||||||
}{
|
}{
|
||||||
{
|
|
||||||
// https://github.com/gohugoio/hugo/issues/7642
|
|
||||||
name: "ignoreVendor as bool",
|
|
||||||
args: []string{"server", "--ignoreVendor"},
|
|
||||||
check: func(c *qt.C, cmd *serverCmd) {
|
|
||||||
cfg := config.New()
|
|
||||||
cmd.flagsToConfig(cfg)
|
|
||||||
c.Assert(cfg.Get("ignoreVendor"), qt.Equals, true)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
// https://github.com/gohugoio/hugo/issues/7642
|
// https://github.com/gohugoio/hugo/issues/7642
|
||||||
name: "ignoreVendorPaths",
|
name: "ignoreVendorPaths",
|
||||||
|
|
|
@ -142,7 +142,7 @@ func (cc *convertCmd) convertAndSavePage(p page.Page, site *hugolib.Site, target
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
errMsg := fmt.Errorf("Error processing file %q", p.Path())
|
errMsg := fmt.Errorf("Error processing file %q", p.File().Path())
|
||||||
|
|
||||||
site.Log.Infoln("Attempting to convert", p.File().Filename())
|
site.Log.Infoln("Attempting to convert", p.File().Filename())
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ func (cc *convertCmd) convertAndSavePage(p page.Page, site *hugolib.Site, target
|
||||||
newFilename := p.File().Filename()
|
newFilename := p.File().Filename()
|
||||||
|
|
||||||
if cc.outputDir != "" {
|
if cc.outputDir != "" {
|
||||||
contentDir := strings.TrimSuffix(newFilename, p.Path())
|
contentDir := strings.TrimSuffix(newFilename, p.File().Path())
|
||||||
contentDir = filepath.Base(contentDir)
|
contentDir = filepath.Base(contentDir)
|
||||||
|
|
||||||
newFilename = filepath.Join(cc.outputDir, contentDir, p.Path())
|
newFilename = filepath.Join(cc.outputDir, contentDir, p.File().Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
fs := hugofs.Os
|
fs := hugofs.Os
|
||||||
|
|
|
@ -199,7 +199,6 @@ func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
|
||||||
"forceSyncStatic",
|
"forceSyncStatic",
|
||||||
"noTimes",
|
"noTimes",
|
||||||
"noChmod",
|
"noChmod",
|
||||||
"ignoreVendor",
|
|
||||||
"ignoreVendorPaths",
|
"ignoreVendorPaths",
|
||||||
"templateMetrics",
|
"templateMetrics",
|
||||||
"templateMetricsHints",
|
"templateMetricsHints",
|
||||||
|
@ -281,7 +280,6 @@ func isTerminal() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) fullBuild(noBuildLock bool) error {
|
func (c *commandeer) fullBuild(noBuildLock bool) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
g errgroup.Group
|
g errgroup.Group
|
||||||
langCount map[string]uint64
|
langCount map[string]uint64
|
||||||
|
@ -542,7 +540,6 @@ func (c *commandeer) build() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) serverBuild() error {
|
func (c *commandeer) serverBuild() error {
|
||||||
|
|
||||||
stopProfiling, err := c.initProfiling()
|
stopProfiling, err := c.initProfiling()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -739,7 +736,6 @@ func (c *commandeer) handleBuildErr(err error, msg string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandeer) rebuildSites(events []fsnotify.Event) error {
|
func (c *commandeer) rebuildSites(events []fsnotify.Event) error {
|
||||||
|
|
||||||
c.buildErr = nil
|
c.buildErr = nil
|
||||||
visited := c.visitedURLs.PeekAllSet()
|
visited := c.visitedURLs.PeekAllSet()
|
||||||
if c.fastRenderMode {
|
if c.fastRenderMode {
|
||||||
|
|
|
@ -96,7 +96,7 @@ func (b *commandsBuilder) newModCmd() *modCmd {
|
||||||
|
|
||||||
const commonUsage = `
|
const commonUsage = `
|
||||||
Note that Hugo will always start out by resolving the components defined in the site
|
Note that Hugo will always start out by resolving the components defined in the site
|
||||||
configuration, provided by a _vendor directory (if no --ignoreVendor flag provided),
|
configuration, provided by a _vendor directory (if no --ignoreVendorPaths flag provided),
|
||||||
Go Modules, or a folder inside the themes directory, in that order.
|
Go Modules, or a folder inside the themes directory, in that order.
|
||||||
|
|
||||||
See https://gohugo.io/hugo-modules/ for more information.
|
See https://gohugo.io/hugo-modules/ for more information.
|
||||||
|
|
|
@ -40,7 +40,6 @@ var (
|
||||||
"mdown", "markdown", "md",
|
"mdown", "markdown", "md",
|
||||||
"asciidoc", "adoc", "ad",
|
"asciidoc", "adoc", "ad",
|
||||||
"rest", "rst",
|
"rest", "rst",
|
||||||
"mmark",
|
|
||||||
"org",
|
"org",
|
||||||
"pandoc", "pdc",
|
"pandoc", "pdc",
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
// LoadConfig loads Hugo configuration into a new Viper and then adds
|
||||||
// a set of defaults.
|
// a set of defaults.
|
||||||
func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (config.Provider, []string, error) {
|
func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provider) error) (config.Provider, []string, error) {
|
||||||
|
|
||||||
if d.Environment == "" {
|
if d.Environment == "" {
|
||||||
d.Environment = hugo.EnvironmentProduction
|
d.Environment = hugo.EnvironmentProduction
|
||||||
}
|
}
|
||||||
|
@ -110,15 +109,8 @@ func LoadConfig(d ConfigSourceDescriptor, doWithConfig ...func(cfg config.Provid
|
||||||
}
|
}
|
||||||
|
|
||||||
// Config deprecations.
|
// 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" {
|
if l.cfg.GetString("markup.defaultMarkdownHandler") == "blackfriday" {
|
||||||
helpers.Deprecated("markup.defaultMarkdownHandler=blackfriday", "See https://gohugo.io//content-management/formats/#list-of-content-formats", false)
|
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,
|
// Some settings are used before we're done collecting all settings,
|
||||||
|
|
|
@ -403,7 +403,7 @@ func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesM
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true
|
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
|
r = rp
|
||||||
|
|
||||||
case files.ContentClassFile:
|
case files.ContentClassFile:
|
||||||
|
@ -468,7 +468,6 @@ func (m *pageMap) assembleSections() error {
|
||||||
|
|
||||||
kind := page.KindSection
|
kind := page.KindSection
|
||||||
if s == "/" {
|
if s == "/" {
|
||||||
|
|
||||||
kind = page.KindHome
|
kind = page.KindHome
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +579,7 @@ func (m *pageMap) attachPageToViews(s string, b *contentNode) {
|
||||||
w := getParamToLower(b.p, viewName.plural+"_weight")
|
w := getParamToLower(b.p, viewName.plural+"_weight")
|
||||||
weight, err := cast.ToIntE(w)
|
weight, err := cast.ToIntE(w)
|
||||||
if err != nil {
|
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
|
// weight will equal zero, so let the flow continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ func (p *pageState) Eq(other interface{}) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageState) GetIdentity() identity.Identity {
|
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 {
|
func (p *pageState) GitInfo() *gitmap.GitInfo {
|
||||||
|
@ -895,8 +895,8 @@ func (p *pageState) pathOrTitle() string {
|
||||||
return p.File().Filename()
|
return p.File().Filename()
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Path() != "" {
|
if p.Pathc() != "" {
|
||||||
return p.Path()
|
return p.Pathc()
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.Title()
|
return p.Title()
|
||||||
|
|
|
@ -232,6 +232,24 @@ func (p *pageMeta) Params() maps.Params {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *pageMeta) Path() string {
|
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() {
|
if !p.File().IsZero() {
|
||||||
return p.File().Path()
|
return p.File().Path()
|
||||||
}
|
}
|
||||||
|
@ -759,7 +777,7 @@ func (p *pageMeta) newContentConverter(ps *pageState, markup string, renderingCo
|
||||||
converter.DocumentContext{
|
converter.DocumentContext{
|
||||||
Document: newPageForRenderHook(ps),
|
Document: newPageForRenderHook(ps),
|
||||||
DocumentID: id,
|
DocumentID: id,
|
||||||
DocumentName: p.Path(),
|
DocumentName: p.File().Path(),
|
||||||
Filename: filename,
|
Filename: filename,
|
||||||
ConfigOverrides: renderingConfigOverrides,
|
ConfigOverrides: renderingConfigOverrides,
|
||||||
},
|
},
|
||||||
|
|
|
@ -689,12 +689,6 @@ func (s *SiteInfo) AllRegularPages() page.Pages {
|
||||||
return s.s.AllRegularPages()
|
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 {
|
func (s *SiteInfo) LastChange() time.Time {
|
||||||
return s.s.lastmod
|
return s.s.lastmod
|
||||||
}
|
}
|
||||||
|
@ -825,7 +819,7 @@ func (s siteRefLinker) logNotFound(ref, what string, p page.Page, position text.
|
||||||
} else if p == nil {
|
} else if p == nil {
|
||||||
s.errorLogger.Printf("[%s] REF_NOT_FOUND: Ref %q: %s", s.s.Lang(), ref, what)
|
s.errorLogger.Printf("[%s] REF_NOT_FOUND: Ref %q: %s", s.s.Lang(), ref, what)
|
||||||
} else {
|
} 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.Errorf("unable to process menus in site config\n")
|
||||||
s.Log.Errorln(err)
|
s.Log.Errorln(err)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range m {
|
for _, entry := range m {
|
||||||
|
|
|
@ -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) {
|
func checkLinkCase(site *Site, link string, currentPage page.Page, relative bool, outputFormat string, expected string, t *testing.T, i int) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if out, err := site.refLink(link, currentPage, relative, outputFormat); err != nil || out != expected {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,6 @@ func (s *sitesBuilder) NpmInstall() hexec.Runner {
|
||||||
command, err := ex.New("npm", "install")
|
command, err := ex.New("npm", "install")
|
||||||
s.Assert(err, qt.IsNil)
|
s.Assert(err, qt.IsNil)
|
||||||
return command
|
return command
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestHelper(cfg config.Provider, fs *hugofs.Fs, t testing.TB) testHelper {
|
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 {
|
func pagesToString(pages ...page.Page) string {
|
||||||
var paths []string
|
var paths []string
|
||||||
for _, p := range pages {
|
for _, p := range pages {
|
||||||
paths = append(paths, p.Path())
|
paths = append(paths, p.Pathc())
|
||||||
}
|
}
|
||||||
sort.Strings(paths)
|
sort.Strings(paths)
|
||||||
return strings.Join(paths, "|")
|
return strings.Join(paths, "|")
|
||||||
|
@ -1020,7 +1019,7 @@ func dumpPages(pages ...page.Page) {
|
||||||
fmt.Println("---------")
|
fmt.Println("---------")
|
||||||
for _, p := range pages {
|
for _, p := range pages {
|
||||||
fmt.Printf("Kind: %s Title: %-10s RelPermalink: %-10s Path: %-10s sections: %s Lang: %s\n",
|
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 {
|
for i, p := range pages {
|
||||||
fmt.Printf("%d: Kind: %s Title: %-10s RelPermalink: %-10s Path: %-10s sections: %s\n",
|
fmt.Printf("%d: Kind: %s Title: %-10s RelPermalink: %-10s Path: %-10s sections: %s\n",
|
||||||
i+1,
|
i+1,
|
||||||
p.Kind(), p.Title(), p.RelPermalink(), p.Path(), p.SectionsPath())
|
p.Kind(), p.Title(), p.RelPermalink(), p.Pathc(), p.SectionsPath())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ func (c *Client) Tidy() error {
|
||||||
//
|
//
|
||||||
// We, by default, use the /_vendor folder first, if found. To disable,
|
// We, by default, use the /_vendor folder first, if found. To disable,
|
||||||
// run with
|
// run with
|
||||||
// hugo --ignoreVendor
|
// hugo --ignoreVendorPaths=".*"
|
||||||
//
|
//
|
||||||
// Given a module tree, Hugo will pick the first module for a given path,
|
// Given a module tree, Hugo will pick the first module for a given path,
|
||||||
// meaning that if the top-level module is vendored, that will be the full
|
// meaning that if the top-level module is vendored, that will be the full
|
||||||
|
|
|
@ -180,6 +180,9 @@ type PageMetaProvider interface {
|
||||||
// to the source of this Page. It will be relative to any content root.
|
// to the source of this Page. It will be relative to any content root.
|
||||||
Path() string
|
Path() string
|
||||||
|
|
||||||
|
// This is just a temporary bridge method. Use Path in templates.
|
||||||
|
Pathc() string
|
||||||
|
|
||||||
// The slug, typically defined in front matter.
|
// The slug, typically defined in front matter.
|
||||||
Slug() string
|
Slug() string
|
||||||
|
|
||||||
|
@ -392,5 +395,4 @@ type DeprecatedWarningPageMethods1 interface {
|
||||||
|
|
||||||
// Move here to trigger ERROR instead of WARNING.
|
// Move here to trigger ERROR instead of WARNING.
|
||||||
// TODO(bep) create wrappers and put into the Page once it has some methods.
|
// TODO(bep) create wrappers and put into the Page once it has some methods.
|
||||||
type DeprecatedErrorPageMethods interface {
|
type DeprecatedErrorPageMethods interface{}
|
||||||
}
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ package page
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"html/template"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/bep/gitmap"
|
"github.com/bep/gitmap"
|
||||||
"github.com/gohugoio/hugo/common/maps"
|
"github.com/gohugoio/hugo/common/maps"
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
|
@ -26,8 +29,6 @@ import (
|
||||||
"github.com/gohugoio/hugo/media"
|
"github.com/gohugoio/hugo/media"
|
||||||
"github.com/gohugoio/hugo/navigation"
|
"github.com/gohugoio/hugo/navigation"
|
||||||
"github.com/gohugoio/hugo/source"
|
"github.com/gohugoio/hugo/source"
|
||||||
"html/template"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func MarshalPageToJSON(p Page) ([]byte, error) {
|
func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||||
|
@ -68,7 +69,7 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
|
||||||
linkTitle := p.LinkTitle()
|
linkTitle := p.LinkTitle()
|
||||||
isNode := p.IsNode()
|
isNode := p.IsNode()
|
||||||
isPage := p.IsPage()
|
isPage := p.IsPage()
|
||||||
path := p.Path()
|
path := p.Pathc()
|
||||||
slug := p.Slug()
|
slug := p.Slug()
|
||||||
lang := p.Lang()
|
lang := p.Lang()
|
||||||
isSection := p.IsSection()
|
isSection := p.IsSection()
|
||||||
|
|
|
@ -59,7 +59,7 @@ func (m PageMatcher) Matches(p Page) bool {
|
||||||
if m.Path != "" {
|
if m.Path != "" {
|
||||||
g, err := glob.GetGlob(m.Path)
|
g, err := glob.GetGlob(m.Path)
|
||||||
// TODO(bep) Path() vs filepath vs leading slash.
|
// TODO(bep) Path() vs filepath vs leading slash.
|
||||||
p := strings.ToLower(filepath.ToSlash(p.Path()))
|
p := strings.ToLower(filepath.ToSlash(p.Pathc()))
|
||||||
if !(strings.HasPrefix(p, "/")) {
|
if !(strings.HasPrefix(p, "/")) {
|
||||||
p = "/" + p
|
p = "/" + p
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,6 @@ func DecodeCascade(in interface{}) (map[PageMatcher]maps.Params, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return cascade, nil
|
return cascade, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodePageMatcher decodes m into v.
|
// DecodePageMatcher decodes m into v.
|
||||||
|
|
|
@ -338,6 +338,10 @@ func (p *nopPage) Path() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *nopPage) Pathc() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (p *nopPage) Permalink() string {
|
func (p *nopPage) Permalink() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,6 +414,10 @@ func (p *testPage) Path() string {
|
||||||
return p.path
|
return p.path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *testPage) Pathc() string {
|
||||||
|
return p.path
|
||||||
|
}
|
||||||
|
|
||||||
func (p *testPage) Permalink() string {
|
func (p *testPage) Permalink() string {
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue