本文整理汇总了Golang中github.com/spf13/hugo/parser.InterfaceToConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang InterfaceToConfig函数的具体用法?Golang InterfaceToConfig怎么用?Golang InterfaceToConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InterfaceToConfig函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createConfig
func createConfig(inpath string, kind string) (err error) {
in := map[string]string{"baseurl": "http://yourSiteHere", "title": "my new hugo site", "languageCode": "en-us"}
kind = parser.FormatSanitize(kind)
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))
if err != nil {
return err
}
err = helpers.WriteToDisk(path.Join(inpath, "config."+kind), bytes.NewReader(by))
if err != nil {
return
}
return nil
}
示例2: createConfig
func createConfig(inpath string, kind string) (err error) {
in := map[string]string{
"baseurl": "http://replace-this-with-your-hugo-site.com/",
"title": "My New Hugo Site",
"languageCode": "en-us",
}
kind = parser.FormatSanitize(kind)
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))
if err != nil {
return err
}
err = helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), bytes.NewReader(by), hugofs.SourceFs)
if err != nil {
return
}
return nil
}
示例3: createConfigFromJekyll
func createConfigFromJekyll(inpath string, kind string, jekyllConfig map[string]interface{}) (err error) {
title := "My New Hugo Site"
baseURL := "http://example.org/"
for key, value := range jekyllConfig {
lowerKey := strings.ToLower(key)
switch lowerKey {
case "title":
if str, ok := value.(string); ok {
title = str
}
case "url":
if str, ok := value.(string); ok {
baseURL = str
}
}
}
in := map[string]interface{}{
"baseURL": baseURL,
"title": title,
"languageCode": "en-us",
"disablePathToLower": true,
}
kind = parser.FormatSanitize(kind)
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune(kind))
if err != nil {
return err
}
err = helpers.WriteToDisk(filepath.Join(inpath, "config."+kind), bytes.NewReader(by), hugofs.Source())
if err != nil {
return
}
return nil
}
示例4: createThemeMD
func createThemeMD(inpath string) (err error) {
in := map[string]interface{}{
"name": helpers.MakeTitle(filepath.Base(inpath)),
"license": "MIT",
"source_repo": "",
"author": "",
"description": "",
"tags": []string{"", ""},
}
by, err := parser.InterfaceToConfig(in, parser.FormatToLeadRune("toml"))
if err != nil {
return err
}
err = helpers.WriteToDisk(path.Join(inpath, "theme.toml"), bytes.NewReader(by))
if err != nil {
return
}
return nil
}