本文整理汇总了Golang中github.com/spf13/hugo/helpers.SanitizeURLKeepTrailingSlash函数的典型用法代码示例。如果您正苦于以下问题:Golang SanitizeURLKeepTrailingSlash函数的具体用法?Golang SanitizeURLKeepTrailingSlash怎么用?Golang SanitizeURLKeepTrailingSlash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SanitizeURLKeepTrailingSlash函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: initializeSiteInfo
func (s *Site) initializeSiteInfo() {
params := viper.GetStringMap("Params")
permalinks := make(PermalinkOverrides)
for k, v := range viper.GetStringMapString("Permalinks") {
permalinks[k] = PathPattern(v)
}
s.Info = SiteInfo{
BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))),
Title: viper.GetString("Title"),
Author: viper.GetStringMap("author"),
Social: viper.GetStringMapString("social"),
LanguageCode: viper.GetString("languagecode"),
Copyright: viper.GetString("copyright"),
DisqusShortname: viper.GetString("DisqusShortname"),
GoogleAnalytics: viper.GetString("GoogleAnalytics"),
RSSLink: s.permalinkStr(viper.GetString("RSSUri")),
BuildDrafts: viper.GetBool("BuildDrafts"),
canonifyURLs: viper.GetBool("CanonifyURLs"),
preserveTaxonomyNames: viper.GetBool("PreserveTaxonomyNames"),
Pages: &s.Pages,
Menus: &s.Menus,
Params: params,
Permalinks: permalinks,
Data: &s.Data,
}
}
开发者ID:maruel,项目名称:hugo,代码行数:28,代码来源:site.go
示例2: doTestShortcodeCrossrefs
func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
var refShortcode string
var expectedBase string
if relative {
refShortcode = "relref"
expectedBase = "/bar"
} else {
refShortcode = "ref"
expectedBase = baseURL
}
path := filepath.FromSlash("blog/post.md")
in := fmt.Sprintf(`{{< %s "%s" >}}`, refShortcode, path)
expected := fmt.Sprintf(`%s/simple/url/`, expectedBase)
templ := tpl.New()
p, _ := pageFromString(simplePageWithURL, path)
p.Node.Site = &SiteInfo{
Pages: &(Pages{p}),
BaseURL: template.URL(helpers.SanitizeURLKeepTrailingSlash(baseURL)),
}
output, err := HandleShortcodes(in, p, templ)
if err != nil {
t.Fatal("Handle shortcode error", err)
}
if output != expected {
t.Errorf("Got\n%q\nExpected\n%q", output, expected)
}
}
开发者ID:vincentsys,项目名称:hugo,代码行数:33,代码来源:embedded_shortcodes_test.go
示例3: initializeSiteInfo
func (s *Site) initializeSiteInfo() {
params := viper.GetStringMap("Params")
permalinks := make(PermalinkOverrides)
for k, v := range viper.GetStringMapString("Permalinks") {
permalinks[k] = PathPattern(v)
}
s.Info = SiteInfo{
BaseUrl: template.URL(helpers.SanitizeURLKeepTrailingSlash(viper.GetString("BaseURL"))),
Title: viper.GetString("Title"),
Author: viper.GetStringMap("author"),
LanguageCode: viper.GetString("languagecode"),
Copyright: viper.GetString("copyright"),
DisqusShortname: viper.GetString("DisqusShortname"),
BuildDrafts: viper.GetBool("BuildDrafts"),
canonifyURLs: viper.GetBool("CanonifyURLs"),
Pages: &s.Pages,
Recent: &s.Pages,
Menus: &s.Menus,
Params: params,
Permalinks: permalinks,
Data: &s.Data,
}
}
开发者ID:sun-friderick,项目名称:hugo,代码行数:25,代码来源:site.go
示例4: createNodeMenuEntryURL
func (s *SiteInfo) createNodeMenuEntryURL(in string) string {
if !strings.HasPrefix(in, "/") {
return in
}
// make it match the nodes
menuEntryURL := in
menuEntryURL = helpers.SanitizeURLKeepTrailingSlash(helpers.URLize(menuEntryURL))
if !s.canonifyURLs {
menuEntryURL = helpers.AddContextRoot(string(s.BaseURL), menuEntryURL)
}
return menuEntryURL
}
开发者ID:michaelsync,项目名称:hugo,代码行数:13,代码来源:site.go
注:本文中的github.com/spf13/hugo/helpers.SanitizeURLKeepTrailingSlash函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论