diff options
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/content_map.go | 30 | ||||
-rw-r--r-- | hugolib/content_map_page.go | 6 | ||||
-rw-r--r-- | hugolib/content_map_test.go | 16 | ||||
-rw-r--r-- | hugolib/filesystems/basefs.go | 41 | ||||
-rw-r--r-- | hugolib/hugo_modules_test.go | 4 | ||||
-rw-r--r-- | hugolib/hugo_sites.go | 10 | ||||
-rw-r--r-- | hugolib/hugo_sites_build.go | 2 | ||||
-rw-r--r-- | hugolib/page.go | 2 | ||||
-rw-r--r-- | hugolib/page__meta.go | 2 | ||||
-rw-r--r-- | hugolib/pagebundler_test.go | 3 | ||||
-rw-r--r-- | hugolib/pagecollections.go | 8 | ||||
-rw-r--r-- | hugolib/pages_capture.go | 53 | ||||
-rw-r--r-- | hugolib/pages_process.go | 8 |
13 files changed, 88 insertions, 97 deletions
diff --git a/hugolib/content_map.go b/hugolib/content_map.go index 3f5ed65c3..29e821f75 100644 --- a/hugolib/content_map.go +++ b/hugolib/content_map.go @@ -101,9 +101,9 @@ func newContentMap(cfg contentMapConfig) *contentMap { n := v.(*contentNode) if n.p != nil && !n.p.File().IsZero() { meta := n.p.File().FileInfo().Meta() - if meta.Path() != meta.PathFile() { + if meta.Path != meta.PathFile() { // Keep track of the original mount source. - mountKey := filepath.ToSlash(filepath.Join(meta.Module(), meta.PathFile())) + mountKey := filepath.ToSlash(filepath.Join(meta.Module, meta.PathFile())) addToReverseMap(mountKey, n, m) } } @@ -198,9 +198,9 @@ func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilde b.newTopLevel() m := b.m meta := fi.Meta() - p := cleanTreeKey(meta.Path()) + p := cleanTreeKey(meta.Path) bundlePath := m.getBundleDir(meta) - isBundle := meta.Classifier().IsBundle() + isBundle := meta.Classifier.IsBundle() if isBundle { panic("not implemented") } @@ -211,7 +211,7 @@ func (b *cmInsertKeyBuilder) WithFile(fi hugofs.FileMetaInfo) *cmInsertKeyBuilde return b } - id := k + m.reduceKeyPart(p, fi.Meta().Path()) + id := k + m.reduceKeyPart(p, fi.Meta().Path) b.tree = b.m.resources b.key = id b.baseKey = p @@ -347,7 +347,7 @@ func (m *contentMap) AddFiles(fis ...hugofs.FileMetaInfo) error { func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hugofs.FileMetaInfo) error { var ( meta = header.Meta() - classifier = meta.Classifier() + classifier = meta.Classifier isBranch = classifier == files.ContentClassBranch bundlePath = m.getBundleDir(meta) @@ -387,7 +387,7 @@ func (m *contentMap) AddFilesBundle(header hugofs.FileMetaInfo, resources ...hug } for _, r := range resources { - rb := b.ForResource(cleanTreeKey(r.Meta().Path())) + rb := b.ForResource(cleanTreeKey(r.Meta().Path)) rb.Insert(&contentNode{fi: r}) } @@ -462,12 +462,12 @@ func (m *contentMap) CreateMissingNodes() error { return nil } -func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { - dir := cleanTreeKey(filepath.Dir(meta.Path())) +func (m *contentMap) getBundleDir(meta *hugofs.FileMeta) string { + dir := cleanTreeKey(filepath.Dir(meta.Path)) - switch meta.Classifier() { + switch meta.Classifier { case files.ContentClassContent: - return path.Join(dir, meta.TranslationBaseName()) + return path.Join(dir, meta.TranslationBaseName) default: return dir } @@ -476,7 +476,7 @@ func (m *contentMap) getBundleDir(meta hugofs.FileMeta) string { func (m *contentMap) newContentNodeFromFi(fi hugofs.FileMetaInfo) *contentNode { return &contentNode{ fi: fi, - path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path()), "/"), + path: strings.TrimPrefix(filepath.ToSlash(fi.Meta().Path), "/"), } } @@ -704,7 +704,7 @@ func (m *contentMap) testDump() string { sb.WriteString("|p:" + c.p.Title()) } if c.fi != nil { - sb.WriteString("|f:" + filepath.ToSlash(c.fi.Meta().Path())) + sb.WriteString("|f:" + filepath.ToSlash(c.fi.Meta().Path)) } return sb.String() } @@ -716,13 +716,13 @@ func (m *contentMap) testDump() string { resourcesPrefix += cmLeafSeparator m.pages.WalkPrefix(s+cmBranchSeparator, func(s string, v interface{}) bool { - sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") + sb.WriteString("\t - P: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n") return false }) } m.resources.WalkPrefix(resourcesPrefix, func(s string, v interface{}) bool { - sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename()) + "\n") + sb.WriteString("\t - R: " + filepath.ToSlash((v.(*contentNode).fi.(hugofs.FileMetaInfo)).Meta().Filename) + "\n") return false }) diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 278d24766..698c96cff 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -117,7 +117,7 @@ func (m *pageMap) newPageFromContentNode(n *contentNode, parentBucket *pagesMapB return nil, err } - if n.fi.Meta().GetBool(walkIsRootFileMetaKey) { + if n.fi.Meta().IsRootFile { // Make sure that the bundle/section we start walking from is always // rendered. // This is only relevant in server fast render mode. @@ -249,7 +249,7 @@ func (m *pageMap) newResource(fim hugofs.FileMetaInfo, owner *pageState) (resour return meta.Open() } - target := strings.TrimPrefix(meta.Path(), owner.File().Dir()) + target := strings.TrimPrefix(meta.Path, owner.File().Dir()) return owner.s.ResourceSpec.New( resources.ResourceSourceDescriptor{ @@ -394,7 +394,7 @@ func (m *pageMap) assembleResources(s string, p *pageState, parentBucket *pagesM m.resources.WalkPrefix(s, func(s string, v interface{}) bool { n := v.(*contentNode) meta := n.fi.Meta() - classifier := meta.Classifier() + classifier := meta.Classifier var r resource.Resource switch classifier { case files.ContentClassContent: diff --git a/hugolib/content_map_test.go b/hugolib/content_map_test.go index a62380efd..014ef9c7d 100644 --- a/hugolib/content_map_test.go +++ b/hugolib/content_map_test.go @@ -51,9 +51,9 @@ func BenchmarkContentMap(b *testing.B) { meta := fi.Meta() // We have a more elaborate filesystem setup in the // real flow, so simulate this here. - meta["lang"] = lang - meta["path"] = meta.Filename() - meta["classifier"] = files.ClassifyContentFile(fi.Name(), meta.GetOpener()) + meta.Lang = lang + meta.Path = meta.Filename + meta.Classifier = files.ClassifyContentFile(fi.Name(), meta.OpenFunc) }) } @@ -109,10 +109,10 @@ func TestContentMap(t *testing.T) { meta := fi.Meta() // We have a more elaborate filesystem setup in the // real flow, so simulate this here. - meta["lang"] = lang - meta["path"] = meta.Filename() - meta["classifier"] = files.ClassifyContentFile(fi.Name(), meta.GetOpener()) - meta["translationBaseName"] = paths.Filename(fi.Name()) + meta.Lang = lang + meta.Path = meta.Filename + meta.TranslationBaseName = paths.Filename(fi.Name()) + meta.Classifier = files.ClassifyContentFile(fi.Name(), meta.OpenFunc) }) } @@ -127,7 +127,7 @@ func TestContentMap(t *testing.T) { header := writeFile(c, fs, "blog/a/index.md", "page") - c.Assert(header.Meta().Lang(), qt.Equals, "en") + c.Assert(header.Meta().Lang, qt.Equals, "en") resources := []hugofs.FileMetaInfo{ writeFile(c, fs, "blog/a/b/data.json", "data"), diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index e977633c8..d238d2e03 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -63,7 +63,7 @@ type BaseFs struct { func (fs *BaseFs) WatchDirs() []hugofs.FileMetaInfo { var dirs []hugofs.FileMetaInfo for _, dir := range fs.AllDirs() { - if dir.Meta().Watch() { + if dir.Meta().Watch { dirs = append(dirs, dir) } } @@ -92,9 +92,9 @@ func (fs *BaseFs) AllDirs() []hugofs.FileMetaInfo { // the given filename. The return value is the path and language code. func (b *BaseFs) RelContentDir(filename string) string { for _, dir := range b.SourceFilesystems.Content.Dirs { - dirname := dir.Meta().Filename() + dirname := dir.Meta().Filename if strings.HasPrefix(filename, dirname) { - rel := path.Join(dir.Meta().Path(), strings.TrimPrefix(filename, dirname)) + rel := path.Join(dir.Meta().Path, strings.TrimPrefix(filename, dirname)) return strings.TrimPrefix(rel, filePathSeparator) } } @@ -108,12 +108,12 @@ func (fs *BaseFs) ResolveJSConfigFile(name string) string { // First look in assets/_jsconfig fi, err := fs.Assets.Fs.Stat(filepath.Join(files.FolderJSConfig, name)) if err == nil { - return fi.(hugofs.FileMetaInfo).Meta().Filename() + return fi.(hugofs.FileMetaInfo).Meta().Filename } // Fall back to the work dir. fi, err = fs.Work.Stat(name) if err == nil { - return fi.(hugofs.FileMetaInfo).Meta().Filename() + return fi.(hugofs.FileMetaInfo).Meta().Filename } return "" @@ -276,11 +276,11 @@ func (s SourceFilesystems) MakeStaticPathRelative(filename string) string { func (d *SourceFilesystem) MakePathRelative(filename string) (string, bool) { for _, dir := range d.Dirs { meta := dir.(hugofs.FileMetaInfo).Meta() - currentPath := meta.Filename() + currentPath := meta.Filename if strings.HasPrefix(filename, currentPath) { rel := strings.TrimPrefix(filename, currentPath) - if mp := meta.Path(); mp != "" { + if mp := meta.Path; mp != "" { rel = filepath.Join(mp, rel) } return strings.TrimPrefix(rel, filePathSeparator), true @@ -295,7 +295,7 @@ func (d *SourceFilesystem) RealFilename(rel string) string { return rel } if realfi, ok := fi.(hugofs.FileMetaInfo); ok { - return realfi.Meta().Filename() + return realfi.Meta().Filename } return rel @@ -304,7 +304,7 @@ func (d *SourceFilesystem) RealFilename(rel string) string { // Contains returns whether the given filename is a member of the current filesystem. func (d *SourceFilesystem) Contains(filename string) bool { for _, dir := range d.Dirs { - if strings.HasPrefix(filename, dir.Meta().Filename()) { + if strings.HasPrefix(filename, dir.Meta().Filename) { return true } } @@ -316,9 +316,9 @@ func (d *SourceFilesystem) Contains(filename string) bool { func (d *SourceFilesystem) Path(filename string) string { for _, dir := range d.Dirs { meta := dir.Meta() - if strings.HasPrefix(filename, meta.Filename()) { - p := strings.TrimPrefix(strings.TrimPrefix(filename, meta.Filename()), filePathSeparator) - if mountRoot := meta.MountRoot(); mountRoot != "" { + if strings.HasPrefix(filename, meta.Filename) { + p := strings.TrimPrefix(strings.TrimPrefix(filename, meta.Filename), filePathSeparator) + if mountRoot := meta.MountRoot; mountRoot != "" { return filepath.Join(mountRoot, p) } return p @@ -333,8 +333,8 @@ func (d *SourceFilesystem) RealDirs(from string) []string { var dirnames []string for _, dir := range d.Dirs { meta := dir.Meta() - dirname := filepath.Join(meta.Filename(), from) - _, err := meta.Fs().Stat(from) + dirname := filepath.Join(meta.Filename, from) + _, err := meta.Fs.Stat(from) if err == nil { dirnames = append(dirnames, dirname) @@ -568,9 +568,10 @@ func (b *sourceFilesystemsBuilder) createModFs( To: filename, ToBasedir: base, Module: md.Module.Path(), - Meta: hugofs.FileMeta{ - "watch": md.Watch(), - "mountWeight": mountWeight, + Meta: &hugofs.FileMeta{ + Watch: md.Watch(), + Weight: mountWeight, + Classifier: files.ContentClassContent, }, } @@ -581,7 +582,7 @@ func (b *sourceFilesystemsBuilder) createModFs( lang = b.p.DefaultContentLanguage } - rm.Meta["lang"] = lang + rm.Meta.Lang = lang if isContentMount { fromToContent = append(fromToContent, rm) @@ -622,7 +623,7 @@ func (b *sourceFilesystemsBuilder) createModFs( lang := l.Lang lfs := rmfsStatic.Filter(func(rm hugofs.RootMapping) bool { - rlang := rm.Meta.Lang() + rlang := rm.Meta.Lang return rlang == "" || rlang == lang }) @@ -676,7 +677,7 @@ func printFs(fs afero.Fs, path string, w io.Writer) { } var filename string if fim, ok := info.(hugofs.FileMetaInfo); ok { - filename = fim.Meta().Filename() + filename = fim.Meta().Filename } fmt.Fprintf(w, " %q %q\n", path, filename) return nil diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go index 96355f08b..ff3d01c04 100644 --- a/hugolib/hugo_modules_test.go +++ b/hugolib/hugo_modules_test.go @@ -993,7 +993,7 @@ title: P1 p := b.GetPage("blog/p1.md") f := p.File().FileInfo().Meta() - b.Assert(filepath.ToSlash(f.Path()), qt.Equals, "blog/p1.md") + b.Assert(filepath.ToSlash(f.Path), qt.Equals, "blog/p1.md") b.Assert(filepath.ToSlash(f.PathFile()), qt.Equals, "content/blog/p1.md") b.Assert(b.H.BaseFs.Layouts.Path(filepath.Join(test.workingDir, "layouts", "_default", "single.html")), qt.Equals, filepath.FromSlash("_default/single.html")) @@ -1046,7 +1046,7 @@ title: P1 b.Assert(p1_2, qt.Equals, p1_1) f := p1_1.File().FileInfo().Meta() - b.Assert(filepath.ToSlash(f.Path()), qt.Equals, "blog/sub/p1.md") + b.Assert(filepath.ToSlash(f.Path), qt.Equals, "blog/sub/p1.md") b.Assert(filepath.ToSlash(f.PathFile()), qt.Equals, "mycontent/sub/p1.md") b.Assert(b.H.BaseFs.Layouts.Path(filepath.Join(myPartialsDir, "mypartial.html")), qt.Equals, filepath.FromSlash("partials/mypartial.html")) b.Assert(b.H.BaseFs.Layouts.Path(filepath.Join(absShortcodesDir, "myshort.html")), qt.Equals, filepath.FromSlash("shortcodes/myshort.html")) diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index d380cf737..a289556ca 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -281,7 +281,7 @@ func (h *HugoSites) GetContentPage(filename string) page.Page { return false } - if b.fi.Meta().Filename() == filename { + if b.fi.Meta().Filename == filename { p = b.p return true } @@ -769,7 +769,7 @@ func (h *HugoSites) removePageByFilename(filename string) { return false } - return b.fi.Meta().Filename() == filename + return b.fi.Meta().Filename == filename }) return nil }) @@ -919,7 +919,7 @@ func (h *HugoSites) errWithFileContext(err error, f source.File) error { return err } - realFilename := fim.Meta().Filename() + realFilename := fim.Meta().Filename err, _ = herrors.WithFileContextForFile( err, @@ -1079,12 +1079,12 @@ func (m *contentChangeMap) resolveAndRemove(filename string) (string, bundleDirT func (m *contentChangeMap) addSymbolicLinkMapping(fim hugofs.FileMetaInfo) { meta := fim.Meta() - if !meta.IsSymlink() { + if !meta.IsSymlink { return } m.symContentMu.Lock() - from, to := meta.Filename(), meta.OriginalFilename() + from, to := meta.Filename, meta.OriginalFilename if fim.IsDir() { if !strings.HasSuffix(from, helpers.FilePathSeparator) { from += helpers.FilePathSeparator diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index ccdf9e435..ab3603cc0 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -356,7 +356,7 @@ func (h *HugoSites) postProcess() error { h.Log.Warnf("Failed to resolve jsconfig.json dir: %s", err) } else { m := fi.(hugofs.FileMetaInfo).Meta() - assetsDir := m.SourceRoot() + assetsDir := m.SourceRoot if strings.HasPrefix(assetsDir, h.ResourceSpec.WorkingDir) { if jsConfig := h.ResourceSpec.JSConfigBuilder.Build(assetsDir); jsConfig != nil { diff --git a/hugolib/page.go b/hugolib/page.go index 6099fb21a..ab2a4d74c 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -1006,7 +1006,7 @@ func (s *Site) sectionsFromFile(fi source.File) []string { parts := strings.Split(dirname, helpers.FilePathSeparator) if fii, ok := fi.(*fileInfo); ok { - if len(parts) > 0 && fii.FileInfo().Meta().Classifier() == files.ContentClassLeaf { + if len(parts) > 0 && fii.FileInfo().Meta().Classifier == files.ContentClassLeaf { // my-section/mybundle/index.md => my-section return parts[:len(parts)-1] } diff --git a/hugolib/page__meta.go b/hugolib/page__meta.go index 3b31cb299..b55f58fe2 100644 --- a/hugolib/page__meta.go +++ b/hugolib/page__meta.go @@ -714,7 +714,7 @@ func (p *pageMeta) applyDefaultValues(n *contentNode) error { } else { source := p.File() if fi, ok := source.(*fileInfo); ok { - class := fi.FileInfo().Meta().Classifier() + class := fi.FileInfo().Meta().Classifier switch class { case files.ContentClassBranch, files.ContentClassLeaf: p.bundleType = class diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index b63d663e3..1694b02ee 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -290,7 +290,8 @@ func TestPageBundlerSiteMultilingual(t *testing.T) { c.Assert(len(s.RegularPages()), qt.Equals, 8) c.Assert(len(s.Pages()), qt.Equals, 16) - // dumpPages(s.AllPages()...) + //dumpPages(s.AllPages()...) + c.Assert(len(s.AllPages()), qt.Equals, 31) bundleWithSubPath := s.getPage(page.KindPage, "lb/index") diff --git a/hugolib/pagecollections.go b/hugolib/pagecollections.go index 623d5de42..811fb6025 100644 --- a/hugolib/pagecollections.go +++ b/hugolib/pagecollections.go @@ -246,8 +246,8 @@ func (c *PageCollections) getContentNode(context page.Page, isReflink bool, ref base = context.SectionsPath() } else { meta := context.File().FileInfo().Meta() - base = filepath.ToSlash(filepath.Dir(meta.Path())) - if meta.Classifier() == files.ContentClassLeaf { + base = filepath.ToSlash(filepath.Dir(meta.Path)) + if meta.Classifier == files.ContentClassLeaf { // Bundles are stored in subfolders e.g. blog/mybundle/index.md, // so if the user has not explicitly asked to go up, // look on the "blog" level. @@ -304,11 +304,11 @@ func (c *PageCollections) getContentNode(context page.Page, isReflink bool, ref var module string if context != nil && !context.File().IsZero() { - module = context.File().FileInfo().Meta().Module() + module = context.File().FileInfo().Meta().Module } if module == "" && !c.pageMap.s.home.File().IsZero() { - module = c.pageMap.s.home.File().FileInfo().Meta().Module() + module = c.pageMap.s.home.File().FileInfo().Meta().Module } if module != "" { diff --git a/hugolib/pages_capture.go b/hugolib/pages_capture.go index 45221af71..da7515fc2 100644 --- a/hugolib/pages_capture.go +++ b/hugolib/pages_capture.go @@ -105,7 +105,7 @@ func (c *pagesCollector) isCascadingEdit(dir contentDirKey) (bool, string) { var isCascade bool c.contentMap.walkBranchesPrefix(prefix, func(s string, n *contentNode) bool { - if n.fi == nil || dir.filename != n.fi.Meta().Filename() { + if n.fi == nil || dir.filename != n.fi.Meta().Filename { return false } @@ -198,7 +198,7 @@ func (c *pagesCollector) Collect() (collectErr error) { default: // We always start from a directory. collectErr = c.collectDir(dir.dirname, true, func(fim hugofs.FileMetaInfo) bool { - return dir.filename == fim.Meta().Filename() + return dir.filename == fim.Meta().Filename }) } @@ -213,12 +213,12 @@ func (c *pagesCollector) Collect() (collectErr error) { } func (c *pagesCollector) isBundleHeader(fi hugofs.FileMetaInfo) bool { - class := fi.Meta().Classifier() + class := fi.Meta().Classifier return class == files.ContentClassLeaf || class == files.ContentClassBranch } func (c *pagesCollector) getLang(fi hugofs.FileMetaInfo) string { - lang := fi.Meta().Lang() + lang := fi.Meta().Lang if lang != "" { return lang } @@ -253,7 +253,7 @@ func (c *pagesCollector) addToBundle(info hugofs.FileMetaInfo, btyp bundleDirTyp } clone := c.cloneFileInfo(source.header) - clone.Meta()["lang"] = lang + clone.Meta().Lang = lang return &fileinfoBundle{ header: clone, @@ -265,10 +265,10 @@ func (c *pagesCollector) addToBundle(info hugofs.FileMetaInfo, btyp bundleDirTyp isBundleHeader := c.isBundleHeader(info) if bundle != nil && isBundleHeader { // index.md file inside a bundle, see issue 6208. - info.Meta()["classifier"] = files.ContentClassContent + info.Meta().Classifier = files.ContentClassContent isBundleHeader = false } - classifier := info.Meta().Classifier() + classifier := info.Meta().Classifier isContent := classifier == files.ContentClassContent if bundle == nil { if isBundleHeader { @@ -295,14 +295,14 @@ func (c *pagesCollector) addToBundle(info hugofs.FileMetaInfo, btyp bundleDirTyp } if classifier == files.ContentClassFile { - translations := info.Meta().Translations() + translations := info.Meta().Translations for lang, b := range bundles { if !stringSliceContains(lang, translations...) && !b.containsResource(info.Name()) { // Clone and add it to the bundle. clone := c.cloneFileInfo(info) - clone.Meta()["lang"] = lang + clone.Meta().Lang = lang b.resources = append(b.resources, clone) } } @@ -312,16 +312,7 @@ func (c *pagesCollector) addToBundle(info hugofs.FileMetaInfo, btyp bundleDirTyp } func (c *pagesCollector) cloneFileInfo(fi hugofs.FileMetaInfo) hugofs.FileMetaInfo { - cm := hugofs.FileMeta{} - meta := fi.Meta() - if meta == nil { - panic(fmt.Sprintf("not meta: %v", fi.Name())) - } - for k, v := range meta { - cm[k] = v - } - - return hugofs.NewFileMetaInfo(fi, cm) + return hugofs.NewFileMetaInfo(fi, hugofs.NewFileMeta()) } func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func(fim hugofs.FileMetaInfo) bool) error { @@ -365,11 +356,11 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func( } filter := func(fim hugofs.FileMetaInfo) bool { - if fim.Meta().SkipDir() { + if fim.Meta().SkipDir { return false } - if c.sp.IgnoreFile(fim.Meta().Filename()) { + if c.sp.IgnoreFile(fim.Meta().Filename) { return false } @@ -393,7 +384,7 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func( } } } - walkRoot := dir.Meta().GetBool(walkIsRootFileMetaKey) + walkRoot := dir.Meta().IsRootFile readdir = filtered // We merge language directories, so there can be duplicates, but they @@ -408,12 +399,10 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func( } meta := fi.Meta() - if walkRoot { - meta[walkIsRootFileMetaKey] = true - } - class := meta.Classifier() - translationBase := meta.TranslationBaseNameWithExt() - key := pth.Join(meta.Lang(), translationBase) + meta.IsRootFile = walkRoot + class := meta.Classifier + translationBase := meta.TranslationBaseNameWithExt + key := pth.Join(meta.Lang, translationBase) if seen[key] { duplicates = append(duplicates, i) @@ -435,10 +424,10 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func( // The branch variant will win because of sort order, but log // a warning about it. if thisBtype > bundleNot && btype > bundleNot && thisBtype != btype { - c.logger.Warnf("Content directory %q have both index.* and _index.* files, pick one.", dir.Meta().Filename()) + c.logger.Warnf("Content directory %q have both index.* and _index.* files, pick one.", dir.Meta().Filename) // Reclassify it so it will be handled as a content file inside the // section, which is in line with the <= 0.55 behaviour. - meta["classifier"] = files.ContentClassContent + meta.Classifier = files.ContentClassContent } else if thisBtype > bundleNot { btype = thisBtype } @@ -488,7 +477,7 @@ func (c *pagesCollector) collectDir(dirname string, partial bool, inFilter func( fim := fi.(hugofs.FileMetaInfo) // Make sure the pages in this directory gets re-rendered, // even in fast render mode. - fim.Meta()[walkIsRootFileMetaKey] = true + fim.Meta().IsRootFile = true w := hugofs.NewWalkway(hugofs.WalkwayConfig{ Fs: c.fs, @@ -517,7 +506,7 @@ func (c *pagesCollector) handleBundleBranch(readdir []hugofs.FileMetaInfo) error meta := fim.Meta() - switch meta.Classifier() { + switch meta.Classifier { case files.ContentClassContent: contentFiles = append(contentFiles, fim) default: diff --git a/hugolib/pages_process.go b/hugolib/pages_process.go index 90b67a717..89a306a3b 100644 --- a/hugolib/pages_process.go +++ b/hugolib/pages_process.go @@ -89,7 +89,7 @@ func (proc *pagesProcessor) Wait() error { } func (proc *pagesProcessor) getProcFromFi(fi hugofs.FileMetaInfo) pagesCollectorProcessorProvider { - if p, found := proc.procs[fi.Meta().Lang()]; found { + if p, found := proc.procs[fi.Meta().Lang]; found { return p } return defaultPageProcessor @@ -151,7 +151,7 @@ func (p *sitePagesProcessor) copyFile(fim hugofs.FileMetaInfo) error { s := p.m.s - target := filepath.Join(s.PathSpec.GetTargetLanguageBasePath(), meta.Path()) + target := filepath.Join(s.PathSpec.GetTargetLanguageBasePath(), meta.Path) defer f.Close() @@ -171,7 +171,7 @@ func (p *sitePagesProcessor) doProcess(item interface{}) error { } meta := v.Meta() - classifier := meta.Classifier() + classifier := meta.Classifier switch classifier { case files.ContentClassContent: if err := m.AddFilesBundle(v); err != nil { @@ -192,5 +192,5 @@ func (p *sitePagesProcessor) doProcess(item interface{}) error { func (p *sitePagesProcessor) shouldSkip(fim hugofs.FileMetaInfo) bool { // TODO(ep) unify - return p.m.s.SourceSpec.DisabledLanguages[fim.Meta().Lang()] + return p.m.s.SourceSpec.DisabledLanguages[fim.Meta().Lang] } |