mirror of
https://github.com/danog/gojekyll.git
synced 2024-12-02 17:17:49 +01:00
28 lines
601 B
Go
28 lines
601 B
Go
|
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:", "")
|
||
|
urls := []string{}
|
||
|
for u, p := range site.Routes {
|
||
|
if !(*dynamicRoutes && p.Static()) {
|
||
|
urls = append(urls, u)
|
||
|
}
|
||
|
}
|
||
|
sort.Strings(urls)
|
||
|
for _, u := range urls {
|
||
|
filename := site.Routes[u].SourcePath()
|
||
|
fmt.Printf(" %s -> %s\n", u, filename)
|
||
|
}
|
||
|
return nil
|
||
|
}
|