mirror of
https://github.com/gohugoio/hugo.git
synced 2024-07-05 08:42:12 +00:00
converted path 2 filepath
This commit is contained in:
parent
7badd2eb0c
commit
4f2dfe7015
|
@ -2,7 +2,7 @@ package target
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
"github.com/spf13/hugo/hugofs"
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
@ -35,7 +35,7 @@ func (fs *Filesystem) Publish(path string, r io.Reader) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *Filesystem) Translate(src string) (dest string, err error) {
|
func (fs *Filesystem) Translate(src string) (dest string, err error) {
|
||||||
return path.Join(fs.PublishDir, src), nil
|
return filepath.Join(fs.PublishDir, src), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *Filesystem) extension(ext string) string {
|
func (fs *Filesystem) extension(ext string) string {
|
||||||
|
@ -43,7 +43,7 @@ func (fs *Filesystem) extension(ext string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func filename(f string) string {
|
func filename(f string) string {
|
||||||
ext := path.Ext(f)
|
ext := filepath.Ext(f)
|
||||||
if ext == "" {
|
if ext == "" {
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package target
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"html/template"
|
"html/template"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
|
@ -41,7 +41,7 @@ func (h *HTMLRedirectAlias) Translate(alias string) (aliasPath string, err error
|
||||||
} else if !strings.HasSuffix(alias, ".html") {
|
} else if !strings.HasSuffix(alias, ".html") {
|
||||||
alias = alias + "/index.html"
|
alias = alias + "/index.html"
|
||||||
}
|
}
|
||||||
return path.Join(h.PublishDir, helpers.MakePath(alias)), nil
|
return filepath.Join(h.PublishDir, helpers.MakePath(alias)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type AliasNode struct {
|
type AliasNode struct {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
"github.com/spf13/hugo/hugofs"
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
@ -34,23 +34,23 @@ func (pp *PagePub) Publish(path string, r io.Reader) (err error) {
|
||||||
func (pp *PagePub) Translate(src string) (dest string, err error) {
|
func (pp *PagePub) Translate(src string) (dest string, err error) {
|
||||||
if src == "/" {
|
if src == "/" {
|
||||||
if pp.PublishDir != "" {
|
if pp.PublishDir != "" {
|
||||||
return path.Join(pp.PublishDir, "index.html"), nil
|
return filepath.Join(pp.PublishDir, "index.html"), nil
|
||||||
}
|
}
|
||||||
return "index.html", nil
|
return "index.html", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, file := path.Split(src)
|
dir, file := filepath.Split(src)
|
||||||
ext := pp.extension(path.Ext(file))
|
ext := pp.extension(filepath.Ext(file))
|
||||||
name := filename(file)
|
name := filename(file)
|
||||||
if pp.PublishDir != "" {
|
if pp.PublishDir != "" {
|
||||||
dir = path.Join(pp.PublishDir, dir)
|
dir = filepath.Join(pp.PublishDir, dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pp.UglyUrls || file == "index.html" {
|
if pp.UglyUrls || file == "index.html" {
|
||||||
return path.Join(dir, fmt.Sprintf("%s%s", name, ext)), nil
|
return filepath.Join(dir, fmt.Sprintf("%s%s", name, ext)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return path.Join(dir, name, fmt.Sprintf("index%s", ext)), nil
|
return filepath.Join(dir, name, fmt.Sprintf("index%s", ext)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pp *PagePub) extension(ext string) string {
|
func (pp *PagePub) extension(ext string) string {
|
||||||
|
|
Loading…
Reference in a new issue