mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
@@ -36,7 +36,6 @@ To create a new view, create a template in each of your different content type d
|
||||
|
||||
Hugo also has support for a default content template to be used in the event that a specific content view template has not been provided for that type. Content views can also be defined in the `_default` directory and will work the same as list and single templates who eventually trickle down to the `_default` directory as a matter of the lookup order.
|
||||
|
||||
|
||||
```txt
|
||||
▾ layouts/
|
||||
▾ _default/
|
||||
@@ -62,7 +61,7 @@ The following example demonstrates how to use content views inside your [list te
|
||||
|
||||
In this example, `.Render` is passed into the template to call the [render function][render]. `.Render` is a special function that instructs content to render itself with the view template provided as the first argument. In this case, the template is going to render the `summary.html` view that follows:
|
||||
|
||||
{{< code file="layouts/_default/list.html" >}}
|
||||
{{< code file=layouts/_default/list.html >}}
|
||||
<main id="main">
|
||||
<div>
|
||||
<h1 id="title">{{ .Title }}</h1>
|
||||
@@ -77,15 +76,15 @@ In this example, `.Render` is passed into the template to call the [render funct
|
||||
|
||||
Hugo will pass the entire page object to the following `summary.html` view template. (See [Page Variables][pagevars] for a complete list.)
|
||||
|
||||
{{< code file="layouts/_default/summary.html" >}}
|
||||
{{< code file=layouts/_default/summary.html >}}
|
||||
<article class="post">
|
||||
<header>
|
||||
<h2><a href='{{ .Permalink }}'> {{ .Title }}</a> </h2>
|
||||
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||
<div class="post-meta">{{ .Date.Format "Mon, Jan 2, 2006" }} - {{ .FuzzyWordCount }} Words </div>
|
||||
</header>
|
||||
{{ .Summary }}
|
||||
<footer>
|
||||
<a href='{{ .Permalink }}'><nobr>Read more →</nobr></a>
|
||||
<a href='{{ .RelPermalink }}'>Read more »</a>
|
||||
</footer>
|
||||
</article>
|
||||
{{< /code >}}
|
||||
@@ -94,9 +93,9 @@ Hugo will pass the entire page object to the following `summary.html` view templ
|
||||
|
||||
Continuing on the previous example, we can change our render function to use a smaller `li.html` view by changing the argument in the call to the `.Render` function (i.e., `{{ .Render "li" }}`).
|
||||
|
||||
{{< code file="layouts/_default/li.html" >}}
|
||||
{{< code file=layouts/_default/li.html >}}
|
||||
<li>
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a>
|
||||
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
<div class="meta">{{ .Date.Format "Mon, Jan 2, 2006" }}</div>
|
||||
</li>
|
||||
{{< /code >}}
|
||||
@@ -104,7 +103,7 @@ Continuing on the previous example, we can change our render function to use a s
|
||||
[lists]: /templates/lists/
|
||||
[lookup]: /templates/lookup-order/
|
||||
[pagevars]: /variables/page/
|
||||
[render]: /functions/render/
|
||||
[render]: /methods/page/render/
|
||||
[single]: /templates/single-page-templates/
|
||||
[spf]: https://spf13.com
|
||||
[spfsourceli]: https://github.com/spf13/spf13.com/blob/master/layouts/_default/li.html
|
||||
|
Reference in New Issue
Block a user