1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-02 14:27:47 +01:00
gojekyll/commands/routes.go

28 lines
598 B
Go
Raw Normal View History

2017-08-11 19:25:51 +02:00
package commands
import (
"fmt"
"sort"
"github.com/osteele/gojekyll/site"
)
var routes = app.Command("routes", "Display site permalinks and associated files")
var dynamicRoutes = routes.Flag("dynamic", "Only show routes to non-static files").Bool()
func routesCommand(site *site.Site) error {
logger.label("Routes:", "")
var urls []string
2017-08-11 19:25:51 +02:00
for u, p := range site.Routes {
2017-09-02 19:53:50 +02:00
if !(*dynamicRoutes && p.IsStatic()) {
2017-08-11 19:25:51 +02:00
urls = append(urls, u)
}
}
sort.Strings(urls)
for _, u := range urls {
2017-09-02 19:53:50 +02:00
filename := site.Routes[u].Source()
2017-08-11 19:25:51 +02:00
fmt.Printf(" %s -> %s\n", u, filename)
}
return nil
}