本文整理汇总了Golang中github.com/spf13/hugo/helpers.MakePathSanitized函数的典型用法代码示例。如果您正苦于以下问题:Golang MakePathSanitized函数的具体用法?Golang MakePathSanitized怎么用?Golang MakePathSanitized使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MakePathSanitized函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newTaxonomyNode
func (s *Site) newTaxonomyNode(t taxRenderInfo) (*Node, string) {
key := t.key
n := s.NewNode()
if s.Info.preserveTaxonomyNames {
key = helpers.MakePathSanitized(key)
// keep as is, just make sure the first char is upper
n.Title = helpers.FirstUpper(t.key)
} else {
n.Title = strings.Replace(strings.Title(t.key), "-", " ", -1)
}
base := t.plural + "/" + key
s.setURLs(n, base)
if len(t.pages) > 0 {
n.Date = t.pages[0].Page.Date
n.Lastmod = t.pages[0].Page.Lastmod
}
n.Data[t.singular] = t.pages
n.Data["Singular"] = t.singular
n.Data["Plural"] = t.plural
n.Data["Pages"] = t.pages.Pages()
return n, base
}
示例2: RenderSectionLists
// RenderSectionLists renders a page for each section
func (s *Site) RenderSectionLists() error {
for section, data := range s.Sections {
// section keys can be lower case (depending on site.pathifyTaxonomyKeys)
// extract the original casing from the first page to get sensible titles.
sectionName := section
if !s.Info.preserveTaxonomyNames && len(data) > 0 {
sectionName = data[0].Page.Section()
}
layouts := s.appendThemeTemplates(
[]string{"section/" + section + ".html", "_default/section.html", "_default/list.html", "indexes/" + section + ".html", "_default/indexes.html"})
if s.Info.preserveTaxonomyNames {
section = helpers.MakePathSanitized(section)
}
n := s.newSectionListNode(sectionName, section, data)
if err := s.renderAndWritePage(fmt.Sprintf("section %s", section), section, n, s.appendThemeTemplates(layouts)...); err != nil {
return err
}
if n.paginator != nil {
paginatePath := viper.GetString("paginatePath")
// write alias for page 1
s.WriteDestAlias(helpers.PaginateAliasPath(section, 1), s.permalink(section))
pagers := n.paginator.Pagers()
for i, pager := range pagers {
if i == 0 {
// already created
continue
}
sectionPagerNode := s.newSectionListNode(sectionName, section, data)
sectionPagerNode.paginator = pager
if pager.TotalPages() > 0 {
first, _ := pager.page(0)
sectionPagerNode.Date = first.Date
sectionPagerNode.Lastmod = first.Lastmod
}
pageNumber := i + 1
htmlBase := fmt.Sprintf("/%s/%s/%d", section, paginatePath, pageNumber)
if err := s.renderAndWritePage(fmt.Sprintf("section %s", section), filepath.FromSlash(htmlBase), sectionPagerNode, layouts...); err != nil {
return err
}
}
}
if !viper.GetBool("DisableRSS") && section != "" {
// XML Feed
rssuri := viper.GetString("RSSUri")
n.URL = s.permalinkStr(section + "/" + rssuri)
n.Permalink = s.permalink(section)
rssLayouts := []string{"section/" + section + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"}
if err := s.renderAndWriteXML("section "+section+" rss", section+"/"+rssuri, n, s.appendThemeTemplates(rssLayouts)...); err != nil {
return err
}
}
}
return nil
}
示例3: kp
// KeyPrep... Taxonomies should be case insensitive. Can make it easily conditional later.
func kp(in string) string {
return helpers.MakePathSanitized(in)
}