本文整理汇总了Golang中github.com/spf13/hugo/helpers.URLizeAndPrep函数的典型用法代码示例。如果您正苦于以下问题:Golang URLizeAndPrep函数的具体用法?Golang URLizeAndPrep怎么用?Golang URLizeAndPrep使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了URLizeAndPrep函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createNodeMenuEntryURL
func (s *SiteInfo) createNodeMenuEntryURL(in string) string {
if !strings.HasPrefix(in, "/") {
return in
}
// make it match the nodes
menuEntryURL := in
menuEntryURL = helpers.URLizeAndPrep(menuEntryURL)
if !s.canonifyURLs {
menuEntryURL = helpers.AddContextRoot(string(s.BaseURL), menuEntryURL)
}
return menuEntryURL
}
示例2: newPaginationURLFactory
func newPaginationURLFactory(pathElements ...string) paginationURLFactory {
paginatePath := viper.GetString("paginatePath")
return func(page int) string {
var rel string
if page == 1 {
rel = fmt.Sprintf("/%s/", path.Join(pathElements...))
} else {
rel = fmt.Sprintf("/%s/%s/%d/", path.Join(pathElements...), paginatePath, page)
}
return helpers.URLizeAndPrep(rel)
}
}
示例3: getMenusFromConfig
func (s *Site) getMenusFromConfig() Menus {
ret := Menus{}
if menus := viper.GetStringMap("menu"); menus != nil {
for name, menu := range menus {
m, err := cast.ToSliceE(menu)
if err != nil {
jww.ERROR.Printf("unable to process menus in site config\n")
jww.ERROR.Println(err)
} else {
for _, entry := range m {
jww.DEBUG.Printf("found menu: %q, in site config\n", name)
menuEntry := MenuEntry{Menu: name}
ime, err := cast.ToStringMapE(entry)
if err != nil {
jww.ERROR.Printf("unable to process menus in site config\n")
jww.ERROR.Println(err)
}
menuEntry.MarshallMap(ime)
if strings.HasPrefix(menuEntry.Url, "/") {
// make it match the nodes
menuEntryURL := menuEntry.Url
menuEntryURL = helpers.URLizeAndPrep(menuEntryURL)
if !s.Info.canonifyURLs {
menuEntryURL = helpers.AddContextRoot(string(s.Info.BaseUrl), menuEntryURL)
}
menuEntry.Url = menuEntryURL
}
if ret[name] == nil {
ret[name] = &Menu{}
}
*ret[name] = ret[name].Add(&menuEntry)
}
}
}
return ret
}
return ret
}
示例4: permalinkStr
func (s *Site) permalinkStr(plink string) string {
return helpers.MakePermalink(string(viper.GetString("BaseURL")), helpers.URLizeAndPrep(plink)).String()
}
示例5: setURLs
func (s *Site) setURLs(n *Node, in string) {
n.URL = helpers.URLizeAndPrep(in)
n.Permalink = s.permalink(n.URL)
n.RSSLink = template.HTML(s.permalink(in + ".xml"))
}
示例6: setUrls
func (s *Site) setUrls(n *Node, in string) {
n.Url = helpers.URLizeAndPrep(in)
n.Permalink = s.permalink(n.Url)
n.RSSLink = s.permalink(in + ".xml")
}