package main import zord_tree "g.arns.lt/zordsdavini/zord-tree" type FSummery struct { Name string Category []string Description string Id string Lang string Tags []string } type TSummery struct { Files []FSummery Tags map[string]int } type FileContent struct { File zord_tree.File Content string } func FormatTreeSummery(tree zord_tree.Tree) TSummery { ts := TSummery{Tags: map[string]int{}} readTree(tree, &ts) return ts } func readTree(tree zord_tree.Tree, ts *TSummery) { for _, subtree := range tree.Dirs { readTree(subtree, ts) } for _, file := range tree.Files { ts.Files = append(ts.Files, FSummery{ Name: file.Name, Category: file.Category, Description: file.Meta["description"], Id: file.Id, Lang: file.Meta["lang"], Tags: file.Tags, }) for _, tag := range file.Tags { ts.Tags[tag]++ } } } func GetContent(file zord_tree.File) FileContent { content, _ := zord_tree.ReadFileContent(file) return FileContent{File: file, Content: content} }