configurable permalinks support

A sample config.yaml for a site might contain:

```yaml
permalinks:
  post: /:year/:month/:title/
```

Then, any article in the `post` section, will have the canonical URL
formed via the permalink specification given.

Signed-off-by: Noah Campbell <noahcampbell@gmail.com>
This commit is contained in:
Phil Pennock
2013-11-18 04:35:56 -05:00
committed by Noah Campbell
parent 4f335f0c7f
commit 07978e4a49
5 changed files with 277 additions and 21 deletions

View File

@@ -34,6 +34,7 @@ type Config struct {
Indexes map[string]string // singular, plural
ProcessFilters map[string][]string
Params map[string]interface{}
Permalinks PermalinkOverrides
BuildDrafts, UglyUrls, Verbose bool
}
@@ -70,6 +71,11 @@ func SetupConfig(cfgfile *string, path *string) *Config {
c.Indexes["category"] = "categories"
}
// ensure map exists, albeit empty
if c.Permalinks == nil {
c.Permalinks = make(PermalinkOverrides, 0)
}
if !strings.HasSuffix(c.BaseUrl, "/") {
c.BaseUrl = c.BaseUrl + "/"
}