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

@@ -46,14 +46,14 @@ func MakePermalink(base *url.URL, path *url.URL) *url.URL {
//
// 2. Pages contain sections (based on the file they were generated from),
// aliases and slugs (included in a pages frontmatter) which are the
// various targets that will get generated. There will be canonical
// listing.
// various targets that will get generated. There will be canonical
// listing. The canonical path can be overruled based on a pattern.
//
// 3. Indexes are created via configuration and will present some aspect of
// the final page and typically a perm url.
//
// 4. All Pages are passed through a template based on their desired
// layout based on numerous different elements.
// layout based on numerous different elements.
//
// 5. The entire collection of files is written to disk.
type Site struct {
@@ -80,6 +80,7 @@ type SiteInfo struct {
LastChange time.Time
Title string
Config *Config
Permalinks PermalinkOverrides
Params map[string]interface{}
}
@@ -220,11 +221,12 @@ func (s *Site) initialize() (err error) {
func (s *Site) initializeSiteInfo() {
s.Info = SiteInfo{
BaseUrl: template.URL(s.Config.BaseUrl),
Title: s.Config.Title,
Recent: &s.Pages,
Config: &s.Config,
Params: s.Config.Params,
BaseUrl: template.URL(s.Config.BaseUrl),
Title: s.Config.Title,
Recent: &s.Pages,
Config: &s.Config,
Params: s.Config.Params,
Permalinks: s.Config.Permalinks,
}
}