1
0
mirror of https://github.com/gohugoio/hugo.git synced 2024-05-11 05:54:58 +00:00

Expand the ShowPlan functionality

This commit is contained in:
Noah Campbell
2013-09-03 20:52:50 -07:00
parent 4004687fb2
commit cb00917af6
5 changed files with 62 additions and 11 deletions

View File

@@ -16,6 +16,11 @@ type Translator interface {
Translate(string) (string, error)
}
type Output interface {
Publisher
Translator
}
type Filesystem struct {
UglyUrls bool
DefaultExtension string
@@ -52,18 +57,24 @@ func (fs *Filesystem) Translate(src string) (dest string, err error) {
if src == "/" {
return "index.html", nil
}
if fs.UglyUrls {
return src, nil
}
dir, file := path.Split(src)
ext := fs.extension(path.Ext(file))
name := filename(file)
if fs.UglyUrls {
return path.Join(dir, fmt.Sprintf("%s%s", name, ext)), nil
}
return path.Join(dir, name, fmt.Sprintf("index%s", ext)), nil
}
func (fs *Filesystem) extension(ext string) string {
switch ext {
case ".md", ".rst": // TODO make this list configurable. page.go has the list of markup types.
return ".html"
}
if ext != "" {
return ext
}