pagemeta: Make BuildConfig.Render an enum

Allowing links on pages without rendering them.

Fixes #7783
This commit is contained in:
Bjørn Erik Pedersen
2020-10-06 11:19:31 +02:00
parent c63db7f1f6
commit 634938908e
6 changed files with 107 additions and 25 deletions

View File

@@ -54,7 +54,15 @@ title: No List
_build:
render: false
---
`, "sect/no-publishresources/index.md", `
`,
"sect/no-render-link.md", `
---
title: No Render Link
_build:
render: link
---
`,
"sect/no-publishresources/index.md", `
---
title: No Publish Resources
_build:
@@ -303,6 +311,20 @@ title: Headless Local Lists Sub
b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil))
})
c.Run("Build config, no render link", func(c *qt.C) {
b := newSitesBuilder(c, disableKind)
b.Build(BuildCfg{})
ref := "/sect/no-render-link.md"
b.Assert(b.CheckExists("public/sect/no-render/index.html"), qt.Equals, false)
p := getPage(b, ref)
b.Assert(p, qt.Not(qt.IsNil))
b.Assert(p.RelPermalink(), qt.Equals, "/blog/sect/no-render-link/")
b.Assert(p.OutputFormats(), qt.HasLen, 0)
b.Assert(getPageInSitePages(b, ref), qt.Not(qt.IsNil))
sect := getPage(b, "/sect")
b.Assert(getPageInPagePages(sect, ref), qt.Not(qt.IsNil))
})
c.Run("Build config, no publish resources", func(c *qt.C) {
b := newSitesBuilder(c, disableKind)
b.Build(BuildCfg{})

View File

@@ -506,7 +506,7 @@ func (pm *pageMeta) setMetadata(parentBucket *pagesMapBucket, p *pageState, fron
pm.params[loki] = isHeadless
if p.File().TranslationBaseName() == "index" && isHeadless {
pm.buildConfig.List = pagemeta.Never
pm.buildConfig.Render = false
pm.buildConfig.Render = pagemeta.Never
}
case "outputs":
o := cast.ToStringSlice(v)
@@ -683,7 +683,11 @@ func (p *pageMeta) getListFilter(local bool) contentTreeNodeCallback {
}
func (p *pageMeta) noRender() bool {
return !p.buildConfig.Render
return p.buildConfig.Render != pagemeta.Always
}
func (p *pageMeta) noLink() bool {
return p.buildConfig.Render == pagemeta.Never
}
func (p *pageMeta) applyDefaultValues(n *contentNode) error {

View File

@@ -51,9 +51,11 @@ func newPagePaths(
var relPermalink, permalink string
// If a page is headless or marked as "no render", or bundled in another,
// If a page is headless or bundled in another,
// it will not get published on its own and it will have no links.
if !pm.noRender() && !pm.bundled {
// We also check the build options if it's set to not render or have
// a link.
if !pm.noLink() && !pm.bundled {
relPermalink = paths.RelPermalink(s.PathSpec)
permalink = paths.PermalinkForOutputFormat(s.PathSpec, f)
}