func loadJekyllConfig(jekyllRoot string) map[string]interface{} { fs := hugofs.SourceFs path := filepath.Join(jekyllRoot, "_config.yml") exists, err := helpers.Exists(path, fs) if err != nil || !exists { return nil } f, err := fs.Open(path) if err != nil { return nil } defer f.Close() b, err := ioutil.ReadAll(f) if err != nil { return nil } c, err := parser.HandleYAMLMetaData(b) if err != nil { return nil } return c.(map[string]interface{}) }
func loadJekyllConfig(jekyllRoot string) map[string]interface{} { fs := hugofs.Source() path := filepath.Join(jekyllRoot, "_config.yml") exists, err := helpers.Exists(path, fs) if err != nil || !exists { jww.WARN.Println("_config.yaml not found: Is the specified Jekyll root correct?") return nil } f, err := fs.Open(path) if err != nil { return nil } defer f.Close() b, err := ioutil.ReadAll(f) if err != nil { return nil } c, err := parser.HandleYAMLMetaData(b) if err != nil { return nil } return c.(map[string]interface{}) }
func readData(f *source.File) (interface{}, error) { switch f.Extension() { case "yaml", "yml": return parser.HandleYAMLMetaData(f.Bytes()) case "json": return parser.HandleJSONMetaData(f.Bytes()) case "toml": return parser.HandleTOMLMetaData(f.Bytes()) default: return nil, fmt.Errorf("Data not supported for extension '%s'", f.Extension()) } }