Skip to content

Commit

Permalink
Document alternative to Summary method
Browse files Browse the repository at this point in the history
  • Loading branch information
jmooring authored Sep 5, 2024
1 parent d053fa1 commit 07c2400
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions content/en/content-management/summaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,18 @@ Render the summary in a template by calling the [`Summary`] method on a `Page` o
</div>
{{ end }}
```

## Alternative

Instead of calling the `Summary` method on a `Page` object, use the [`strings.Truncate`] function for granular control of the summary length. For example:

[`strings.Truncate`]: /functions/strings/truncate/

```go-html-template
{{ range site.RegularPages }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
<div class="summary">
{{ .Content | strings.Truncate 42 }}
</div>
{{ end }}
```

0 comments on commit 07c2400

Please sign in to comment.