Commit 171fd34b authored by Matthew Holt's avatar Matthew Holt

markdown: Make base path optional, always generate links

The base path being optional in the Caddyfile is convenient when you just want the whole site to be markdown-enabled. The other change is to always generate links... this is because an index page for markdown files may not be statically generated, but it should still show links. Commit 09341fca was a regression, and this fixes it.
parent be9f6444
......@@ -61,10 +61,15 @@ func markdownParse(c *Controller) ([]*markdown.Config, error) {
}
// Get the path scope
if !c.NextArg() || c.Val() == "{" {
args := c.RemainingArgs()
switch len(args) {
case 0:
md.PathScope = "/"
case 1:
md.PathScope = args[0]
default:
return mdconfigs, c.ArgErr()
}
md.PathScope = c.Val()
// Load any other configuration parameters
for c.NextBlock() {
......
......@@ -17,22 +17,24 @@ import (
// It only generates static files if it is enabled (cfg.StaticDir
// must be set).
func GenerateStatic(md Markdown, cfg *Config) error {
// If static site generation is enabled.
if cfg.StaticDir != "" {
generated, err := generateLinks(md, cfg)
if err != nil {
return err
}
// Generate links since they may be needed, even without sitegen.
generated, err := generateLinks(md, cfg)
if err != nil {
return err
}
// No new file changes, return.
if !generated {
return nil
}
// No new file changes, return.
if !generated {
return nil
}
// If static site generation is enabled, generate the site.
if cfg.StaticDir != "" {
if err := generateStaticHTML(md, cfg); err != nil {
return err
}
}
return nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment