mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
d57be11324
commit
ead5799f7e
4 changed files with 32 additions and 5 deletions
|
@ -830,6 +830,13 @@ var (
|
||||||
}
|
}
|
||||||
return n.p.m.noRender()
|
return n.p.m.noRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contentTreeNoLinkFilter = func(s string, n *contentNode) bool {
|
||||||
|
if n.p == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return n.p.m.noLink()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) {
|
func (c *contentTree) WalkQuery(query pageMapQuery, walkFn contentTreeNodeCallback) {
|
||||||
|
@ -865,6 +872,13 @@ func (c contentTrees) WalkRenderable(fn contentTreeNodeCallback) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c contentTrees) WalkLinkable(fn contentTreeNodeCallback) {
|
||||||
|
query := pageMapQuery{Filter: contentTreeNoLinkFilter}
|
||||||
|
for _, tree := range c {
|
||||||
|
tree.WalkQuery(query, fn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c contentTrees) Walk(fn contentTreeNodeCallback) {
|
func (c contentTrees) Walk(fn contentTreeNodeCallback) {
|
||||||
for _, tree := range c {
|
for _, tree := range c {
|
||||||
tree.Walk(func(s string, v interface{}) bool {
|
tree.Walk(func(s string, v interface{}) bool {
|
||||||
|
|
|
@ -58,6 +58,7 @@ _build:
|
||||||
"sect/no-render-link.md", `
|
"sect/no-render-link.md", `
|
||||||
---
|
---
|
||||||
title: No Render Link
|
title: No Render Link
|
||||||
|
aliases: ["/link-alias"]
|
||||||
_build:
|
_build:
|
||||||
render: link
|
render: link
|
||||||
---
|
---
|
||||||
|
@ -319,10 +320,14 @@ title: Headless Local Lists Sub
|
||||||
p := getPage(b, ref)
|
p := getPage(b, ref)
|
||||||
b.Assert(p, qt.Not(qt.IsNil))
|
b.Assert(p, qt.Not(qt.IsNil))
|
||||||
b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/")
|
b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/")
|
||||||
b.Assert(p.OutputFormats(), qt.HasLen, 0)
|
b.Assert(p.OutputFormats(), qt.HasLen, 1)
|
||||||
b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil))
|
b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil))
|
||||||
sect := getPage(b, "/sect")
|
sect := getPage(b, "/sect")
|
||||||
b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil))
|
b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil))
|
||||||
|
|
||||||
|
// https://github.com/gohugoio/hugo/issues/7832
|
||||||
|
// It should still render any aliases.
|
||||||
|
b.AssertFileContent("public/link-alias/index.html", "refresh")
|
||||||
})
|
})
|
||||||
|
|
||||||
c.Run("Build config, no publish resources", func(c *qt.C) {
|
c.Run("Build config, no publish resources", func(c *qt.C) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ func newPagePaths(
|
||||||
}
|
}
|
||||||
|
|
||||||
var out page.OutputFormats
|
var out page.OutputFormats
|
||||||
if !pm.noRender() {
|
if !pm.noLink() {
|
||||||
out = pageOutputFormats
|
out = pageOutputFormats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -323,20 +323,28 @@ func (s *Site) renderRobotsTXT() error {
|
||||||
// renderAliases renders shell pages that simply have a redirect in the header.
|
// renderAliases renders shell pages that simply have a redirect in the header.
|
||||||
func (s *Site) renderAliases() error {
|
func (s *Site) renderAliases() error {
|
||||||
var err error
|
var err error
|
||||||
s.pageMap.pageTrees.WalkRenderable(func(ss string, n *contentNode) bool {
|
s.pageMap.pageTrees.WalkLinkable(func(ss string, n *contentNode) bool {
|
||||||
p := n.p
|
p := n.p
|
||||||
if len(p.Aliases()) == 0 {
|
if len(p.Aliases()) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pathSeen := make(map[string]bool)
|
||||||
|
|
||||||
for _, of := range p.OutputFormats() {
|
for _, of := range p.OutputFormats() {
|
||||||
if !of.Format.IsHTML {
|
if !of.Format.IsHTML {
|
||||||
return false
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
plink := of.Permalink()
|
|
||||||
f := of.Format
|
f := of.Format
|
||||||
|
|
||||||
|
if pathSeen[f.Path] {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
pathSeen[f.Path] = true
|
||||||
|
|
||||||
|
plink := of.Permalink()
|
||||||
|
|
||||||
for _, a := range p.Aliases() {
|
for _, a := range p.Aliases() {
|
||||||
isRelative := !strings.HasPrefix(a, "/")
|
isRelative := !strings.HasPrefix(a, "/")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue