2017-08-11 19:25:51 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
2022-01-29 20:17:23 +01:00
|
|
|
"github.com/danog/gojekyll/site"
|
2017-08-11 19:25:51 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
var render = app.Command("render", "Render a file or URL path to standard output")
|
|
|
|
var renderPath = render.Arg("PATH", "Path or URL").String()
|
|
|
|
|
|
|
|
func renderCommand(site *site.Site) error {
|
|
|
|
p, err := pageFromPathOrRoute(site, *renderPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-02 19:53:50 +02:00
|
|
|
logger.path("Render:", filepath.Join(site.SourceDir(), p.Source()))
|
|
|
|
logger.label("URL:", p.URL())
|
2017-08-11 19:25:51 +02:00
|
|
|
logger.label("Content:", "")
|
|
|
|
return site.WriteDocument(os.Stdout, p)
|
|
|
|
}
|