本文整理汇总了Golang中github.com/spf13/hugo/helpers.FirstUpper函数的典型用法代码示例。如果您正苦于以下问题:Golang FirstUpper函数的具体用法?Golang FirstUpper怎么用?Golang FirstUpper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FirstUpper函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newSectionListNode
func (s *Site) newSectionListNode(sectionName, section string, data WeightedPages) *Node {
n := s.NewNode()
sectionName = helpers.FirstUpper(sectionName)
if viper.GetBool("PluralizeListTitles") {
n.Title = inflect.Pluralize(sectionName)
} else {
n.Title = sectionName
}
s.setURLs(n, section)
n.Date = data[0].Page.Date
n.Lastmod = data[0].Page.Lastmod
n.Data["Pages"] = data.Pages()
return n
}
示例2: 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
}
示例3: assembleMenus
func (s *Site) assembleMenus() {
type twoD struct {
MenuName, EntryName string
}
flat := map[twoD]*MenuEntry{}
children := map[twoD]Menu{}
menuConfig := s.getMenusFromConfig()
for name, menu := range menuConfig {
for _, me := range *menu {
flat[twoD{name, me.KeyName()}] = me
}
}
sectionPagesMenu := viper.GetString("SectionPagesMenu")
sectionPagesMenus := make(map[string]interface{})
//creating flat hash
for _, p := range s.Pages {
if sectionPagesMenu != "" {
if _, ok := sectionPagesMenus[p.Section()]; !ok {
if p.Section() != "" {
me := MenuEntry{Identifier: p.Section(), Name: helpers.MakeTitle(helpers.FirstUpper(p.Section())), URL: s.Info.createNodeMenuEntryURL("/" + p.Section())}
if _, ok := flat[twoD{sectionPagesMenu, me.KeyName()}]; ok {
// menu with same id defined in config, let that one win
continue
}
flat[twoD{sectionPagesMenu, me.KeyName()}] = &me
sectionPagesMenus[p.Section()] = true
}
}
}
for name, me := range p.Menus() {
if _, ok := flat[twoD{name, me.KeyName()}]; ok {
jww.ERROR.Printf("Two or more menu items have the same name/identifier in Menu %q: %q.\nRename or set an unique identifier.\n", name, me.KeyName())
continue
}
flat[twoD{name, me.KeyName()}] = me
}
}
// Create Children Menus First
for _, e := range flat {
if e.Parent != "" {
children[twoD{e.Menu, e.Parent}] = children[twoD{e.Menu, e.Parent}].Add(e)
}
}
// Placing Children in Parents (in flat)
for p, childmenu := range children {
_, ok := flat[twoD{p.MenuName, p.EntryName}]
if !ok {
// if parent does not exist, create one without a URL
flat[twoD{p.MenuName, p.EntryName}] = &MenuEntry{Name: p.EntryName, URL: ""}
}
flat[twoD{p.MenuName, p.EntryName}].Children = childmenu
}
// Assembling Top Level of Tree
for menu, e := range flat {
if e.Parent == "" {
_, ok := s.Menus[menu.MenuName]
if !ok {
s.Menus[menu.MenuName] = &Menu{}
}
*s.Menus[menu.MenuName] = s.Menus[menu.MenuName].Add(e)
}
}
}