// As loaded from the /data dirs
data map[string]interface{}
- content *pageMaps
+ contentInit sync.Once
+ content *pageMaps
// Keeps track of bundle directories and symlinks to enable partial rebuilding.
ContentChanges *contentChangeMap
*testCounters
}
+func (h *HugoSites) getContentMaps() *pageMaps {
+ h.contentInit.Do(func() {
+ h.content = newPageMaps(h)
+ })
+ return h.content
+}
+
// Only used in tests.
type testCounters struct {
contentRenderCounter uint64
func (h *HugoSites) GetContentPage(filename string) page.Page {
var p page.Page
- h.content.walkBundles(func(b *contentNode) bool {
+ h.getContentMaps().walkBundles(func(b *contentNode) bool {
if b.p == nil || b.fi == nil {
return false
}
}
func (h *HugoSites) removePageByFilename(filename string) {
- h.content.withMaps(func(m *pageMap) error {
+ h.getContentMaps().withMaps(func(m *pageMap) error {
m.deleteBundleMatching(func(b *contentNode) bool {
if b.p == nil {
return false
}
func (h *HugoSites) resetPageState() {
- h.content.walkBundles(func(n *contentNode) bool {
+ h.getContentMaps().walkBundles(func(n *contentNode) bool {
if n.p == nil {
return false
}
}
func (h *HugoSites) resetPageStateFromEvents(idset identity.Identities) {
- h.content.walkBundles(func(n *contentNode) bool {
+ h.getContentMaps().walkBundles(func(n *contentNode) bool {
if n.p == nil {
return false
}
proc := newPagesProcessor(s.h, sourceSpec)
- c := newPagesCollector(sourceSpec, s.h.content, s.Log, s.h.ContentChanges, proc, filenames...)
+ c := newPagesCollector(sourceSpec, s.h.getContentMaps(), s.Log, s.h.ContentChanges, proc, filenames...)
if err := c.Collect(); err != nil {
return err
}
- s.h.content = newPageMaps(s.h)
-
return nil
}