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:", "")
|
2017-09-02 20:09:04 +02:00
|
|
|
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
|
|
|
|
}
|