Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #523 from kaushalmodi/build-front-matter
Add test for _build front-matter
- Loading branch information
Showing
5 changed files
with
154 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
+++ | ||
title = "_build Front-matter" | ||
tags = ["front-matter", "page-bundles", "_build"] | ||
draft = false | ||
+++ | ||
|
||
`ox-hugo` Issue #[358](https://github.com/kaushalmodi/ox-hugo/issues/358) | [Hugo v0.65.0 release notes](https://gohugo.io/news/0.65.0-relnotes/#new-in-hugo-core) | ||
|
||
{{< getpage1.inline >}} | ||
{{ with site.GetPage "do-not-list" }} | ||
<h2>"do-not-list"</h2> | ||
<p> | ||
Found "do-not-list" page -> <a href="{{ .Permalink }}">{{ .Title }}</a> | ||
</p> | ||
<p> | ||
<strong>Content</strong>: | ||
<blockquote>{{ .Content }}</blockquote> | ||
</p> | ||
{{ end }} | ||
{{< /getpage1.inline >}} | ||
|
||
{{< getpage2.inline >}} | ||
{{ with site.GetPage "do-not-render" }} | ||
<h2>"do-not-render"</h2> | ||
<p> | ||
Found "do-not-render" page -> <a href="{{ .Permalink }}">{{ .Title }}</a> (<mark>As this page is not | ||
technically rendered, this link doesn't actually link to that page; it just links to its parent page.</mark>) | ||
</p> | ||
<p> | ||
<strong>Content</strong>: | ||
<blockquote>{{ .Content }}</blockquote> | ||
{{ end }} | ||
</p> | ||
{{< /getpage2.inline >}} | ||
|
||
--- | ||
|
||
Note | ||
: An [_inline shortcode_](https://gohugo.io/templates/shortcode-templates/#inline-shortcodes) is used above. `enableInlineShortcodes | ||
= true` needs to be added to the site config for that to work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
+++ | ||
title = "_build: Don't list this page" | ||
description = "Build this page but don't list it in _list_ pages." | ||
tags = ["front-matter", "page-bundles", "_build", "dont-list"] | ||
draft = false | ||
[_build] | ||
list = false | ||
+++ | ||
|
||
**This is the "do not list" page.** | ||
|
||
See the [parent](../) list page -- This page is found using the `.GetPage` | ||
method there, but it won't be listed there under "Posts in | ||
‘posts/build-front-matter/’". |
19 changes: 19 additions & 0 deletions
19
test/site/content/posts/build-front-matter/do-not-render.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
+++ | ||
title = "_build: Don't render this page" | ||
description = "Do not render this page, but.. still list it." | ||
tags = ["front-matter", "page-bundles", "_build", "dont-render"] | ||
draft = false | ||
[_build] | ||
render = false | ||
+++ | ||
|
||
**This is the "do not render" page.** | ||
|
||
See the [parent](../) list page -- This page is not rendered, but its content | ||
and metadata can be found using the `site.GetPage` method. This page | ||
also listed on that parent list page, but the link won't lead to this | ||
page as.. it did not get rendered. | ||
|
||
So, with the `_build.render` set to `false`, this page kind of behaves | ||
like a [Page Resource](https://gohugo.io/content-management/page-resources) of "page" _ResourceType_. So we can still access | ||
this page's `.Content` and other metadata like `.Title`, etc. |