Truncated; .Site.Params; First function

* Add `.Truncated` bool to each page; will be set true if the
  `.Summary` is truncated and it's worth showing a "more" link of some
  kind.
* Add `Params` to the site config, defining `.Site.Params` accessible
  to each page; this lets the site maintainer associate arbitrary data
  with names, on a site-wide basis.
* Provide a `First` function to templates:
  * Use-case: `{{range First 5 .Site.Recent}}` or anything else which
    is a simple iterable provided by hugolib
* Tests by me for `.Truncated` and `First`

Also @noahcampbell contributed towards this:

* Add UnitTest for `.Site.Params`:
> Digging into this test case a bit more, I'm realizing that we need
> to create a param test case to ensure that for each type we render
> (page, index, homepage, rss, etc.) that the proper fields are
> represented.  This will help us refactor without fear in the
> future.

Sample config.yaml:

```yaml
title: "Test site"
params:
  Subtitle: "More tests always good"
  AuthorName: "John Doe"
  SidebarRecentLimit: 5
```

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
This commit is contained in:
Phil Pennock
2013-11-10 12:04:51 -08:00
committed by Noah Campbell
parent 6017599a3c
commit 40d05f12a7
7 changed files with 157 additions and 9 deletions

View File

@@ -70,6 +70,7 @@ type Site struct {
Alias target.AliasPublisher
Completed chan bool
RunMode runmode
params map[string]interface{}
}
type SiteInfo struct {
@@ -79,6 +80,7 @@ type SiteInfo struct {
LastChange time.Time
Title string
Config *Config
Params map[string]interface{}
}
type runmode struct {
@@ -222,6 +224,7 @@ func (s *Site) initializeSiteInfo() {
Title: s.Config.Title,
Recent: &s.Pages,
Config: &s.Config,
Params: s.Config.Params,
}
}