Skip to content

Commit

Permalink
adding previous next capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
spf13 committed Aug 2, 2013
1 parent d36d7fb commit ddad1e0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ If you don't intend to contribute, it's even easier.
#### Running Hugo

cd /path/to/hugo
go install github.com/spf13/hugo/hugolibs
go run main.go

#### Building Hugo
Expand Down Expand Up @@ -118,7 +119,7 @@ An example directory may look like:
| | └── youtube.html
| ├── index.html
| └── rss.xml
└── public
└── static

This directory structure tells us a lot about this site:

Expand Down Expand Up @@ -185,8 +186,9 @@ Make sure either hugo is in your path or provide a path to it.
$ hugo --help
usage: hugo [flags] []
-b, --base-url="": hostname (and path) to the root eg. http://spf13.com/
-d, --build-drafts=false: include content marked as draft
-D, --build-drafts=false: include content marked as draft
--config="": config file (default is path/config.yaml|json|toml)
-d, --destination="": filesystem path to write files to
-h, --help=false: show this help
--port="1313": port to run web server on, default :1313
-S, --server=false: run a (very) simple web server
Expand Down Expand Up @@ -214,13 +216,15 @@ your browser to view the changes.**
Watching for changes. Press ctrl+c to stop
15 pages created
0 tags created
in 8 ms

Hugo can even run a server and create your site at the same time!

$hugo --server -ws ~/mysite
Watching for changes. Press ctrl+c to stop
15 pages created
0 tags created
in 8 ms
Web Server is available at http://localhost:1313
Press ctrl+c to stop

Expand Down Expand Up @@ -527,6 +531,17 @@ To check if a parameter has been provided use the isset method provided by Hugo.

## Release Notes

* **0.8.0** August 1, 2013
* Added support for pretty urls (filename/index.html vs filename.html)
* Hugo supports a destination directory
* Will efficiently sync content in static to destination directory
* Cleaned up options.. now with support for short and long options
* Added support for TOML
* Added support for YAML
* Added support for Previous & Next
* Support for Series
* Adding verbose output
* Loads of bugfixes
* **0.7.0** July 4, 2013
* Hugo now includes a simple server
* First public release
Expand All @@ -544,8 +559,6 @@ In no particular order, here is what I'm working on:
* Syntax highlighting
* Previous & Next
* Related Posts
* Support for TOML front matter -- in head
* Proper YAML support for front matter -- in head
* Support for other formats

## Contributing
Expand Down
17 changes: 15 additions & 2 deletions hugolib/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package hugolib
import (
"bitbucket.org/pkg/inflect"
"bytes"
"errors"
"fmt"
"github.com/spf13/nitro"
"html/template"
Expand All @@ -24,7 +25,6 @@ import (
"path/filepath"
"strings"
"time"
"errors"
//"sync"
)

Expand Down Expand Up @@ -74,11 +74,12 @@ func (site *Site) Analyze() {
site.checkDescriptions()
}

func (site *Site) Process() (err error){
func (site *Site) Process() (err error) {
site.initialize()
site.prepTemplates()
site.timer.Step("initialize & template prep")
site.CreatePages()
site.setupPrevNext()
site.timer.Step("import pages")
if err = site.BuildSiteMeta(); err != nil {
return
Expand Down Expand Up @@ -220,6 +221,18 @@ func (s *Site) CreatePages() {
s.Pages.Sort()
}

func (s *Site) setupPrevNext() {
for i, _ := range s.Pages {
if i < len(s.Pages)-1 {
s.Pages[i].Next = s.Pages[i+1]
}

if i > 0 {
s.Pages[i].Prev = s.Pages[i-1]
}
}
}

func (s *Site) BuildSiteMeta() (err error) {
s.Indexes = make(IndexList)
s.Sections = make(Index)
Expand Down

0 comments on commit ddad1e0

Please sign in to comment.