本文整理汇总了Golang中github.com/spf13/hugo/helpers.MakePath函数的典型用法代码示例。如果您正苦于以下问题:Golang MakePath函数的具体用法?Golang MakePath怎么用?Golang MakePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakePath函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: permalink
func (p *Page) permalink() (*url.URL, error) {
baseURL := string(p.Site.BaseURL)
dir := strings.TrimSpace(helpers.MakePath(filepath.ToSlash(strings.ToLower(p.Source.Dir()))))
pSlug := strings.TrimSpace(helpers.URLize(p.Slug))
pURL := strings.TrimSpace(helpers.URLize(p.URL))
var permalink string
var err error
if len(pURL) > 0 {
return helpers.MakePermalink(baseURL, pURL), nil
}
if override, ok := p.Site.Permalinks[p.Section()]; ok {
permalink, err = override.Expand(p)
if err != nil {
return nil, err
}
// fmt.Printf("have a section override for %q in section %s → %s\n", p.Title, p.Section, permalink)
} else {
if len(pSlug) > 0 {
permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, p.Slug+"."+p.Extension()))
} else {
_, t := filepath.Split(p.Source.LogicalName())
permalink = helpers.URLPrep(viper.GetBool("UglyURLs"), path.Join(dir, helpers.ReplaceExtension(strings.TrimSpace(t), p.Extension())))
}
}
return helpers.MakePermalink(baseURL, permalink), nil
}
示例2: Translate
func (h *HTMLRedirectAlias) Translate(alias string) (aliasPath string, err error) {
if len(alias) <= 0 {
return
}
if strings.HasSuffix(alias, "/") {
alias = alias + "index.html"
} else if !strings.HasSuffix(alias, ".html") {
alias = alias + "/index.html"
}
return filepath.Join(h.PublishDir, helpers.MakePath(alias)), nil
}
示例3: TargetPath
func (p *Page) TargetPath() (outfile string) {
// Always use URL if it's specified
if len(strings.TrimSpace(p.URL)) > 2 {
outfile = strings.TrimSpace(p.URL)
if strings.HasSuffix(outfile, "/") {
outfile = outfile + "index.html"
}
outfile = filepath.FromSlash(outfile)
return
}
// If there's a Permalink specification, we use that
if override, ok := p.Site.Permalinks[p.Section()]; ok {
var err error
outfile, err = override.Expand(p)
if err == nil {
outfile, _ = url.QueryUnescape(outfile)
if strings.HasSuffix(outfile, "/") {
outfile += "index.html"
}
outfile = filepath.FromSlash(outfile)
return
}
}
if len(strings.TrimSpace(p.Slug)) > 0 {
outfile = strings.TrimSpace(p.Slug) + "." + p.Extension()
} else {
// Fall back to filename
outfile = helpers.ReplaceExtension(p.Source.LogicalName(), p.Extension())
}
return filepath.Join(strings.ToLower(helpers.MakePath(p.Source.Dir())), strings.TrimSpace(outfile))
}
示例4: kp
// KeyPrep... Indexes should be case insensitive. Can make it easily conditional later.
func kp(in string) string {
return helpers.MakePath(in)
}