github.com/kovansky/hugo@v0.92.3-0.20220224232819-63076e4ff19f/hugolib/page__common.go (about) 1 // Copyright 2019 The Hugo Authors. All rights reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // http://www.apache.org/licenses/LICENSE-2.0 7 // 8 // Unless required by applicable law or agreed to in writing, software 9 // distributed under the License is distributed on an "AS IS" BASIS, 10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package hugolib 15 16 import ( 17 "sync" 18 19 "github.com/bep/gitmap" 20 "github.com/gohugoio/hugo/common/maps" 21 "github.com/gohugoio/hugo/compare" 22 "github.com/gohugoio/hugo/lazy" 23 "github.com/gohugoio/hugo/navigation" 24 "github.com/gohugoio/hugo/output" 25 "github.com/gohugoio/hugo/resources/page" 26 "github.com/gohugoio/hugo/resources/resource" 27 ) 28 29 type treeRefProvider interface { 30 getTreeRef() *contentTreeRef 31 } 32 33 func (p *pageCommon) getTreeRef() *contentTreeRef { 34 return p.treeRef 35 } 36 37 type nextPrevProvider interface { 38 getNextPrev() *nextPrev 39 } 40 41 func (p *pageCommon) getNextPrev() *nextPrev { 42 return p.posNextPrev 43 } 44 45 type nextPrevInSectionProvider interface { 46 getNextPrevInSection() *nextPrev 47 } 48 49 func (p *pageCommon) getNextPrevInSection() *nextPrev { 50 return p.posNextPrevSection 51 } 52 53 type pageCommon struct { 54 s *Site 55 m *pageMeta 56 57 bucket *pagesMapBucket 58 treeRef *contentTreeRef 59 60 // Lazily initialized dependencies. 61 init *lazy.Init 62 63 // Store holds state that survives server rebuilds. 64 store *maps.Scratch 65 66 // All of these represents the common parts of a page.Page 67 maps.Scratcher 68 navigation.PageMenusProvider 69 page.AuthorProvider 70 page.AlternativeOutputFormatsProvider 71 page.ChildCareProvider 72 page.FileProvider 73 page.GetPageProvider 74 page.GitInfoProvider 75 page.InSectionPositioner 76 page.OutputFormatsProvider 77 page.PageMetaProvider 78 page.Positioner 79 page.RawContentProvider 80 page.RelatedKeywordsProvider 81 page.RefProvider 82 page.ShortcodeInfoProvider 83 page.SitesProvider 84 page.TranslationsProvider 85 page.TreeProvider 86 resource.LanguageProvider 87 resource.ResourceDataProvider 88 resource.ResourceMetaProvider 89 resource.ResourceParamsProvider 90 resource.ResourceTypeProvider 91 resource.MediaTypeProvider 92 resource.TranslationKeyProvider 93 compare.Eqer 94 95 // Describes how paths and URLs for this page and its descendants 96 // should look like. 97 targetPathDescriptor page.TargetPathDescriptor 98 99 layoutDescriptor output.LayoutDescriptor 100 layoutDescriptorInit sync.Once 101 102 // The parsed page content. 103 pageContent 104 105 // Set if feature enabled and this is in a Git repo. 106 gitInfo *gitmap.GitInfo 107 codeowners []string 108 109 // Positional navigation 110 posNextPrev *nextPrev 111 posNextPrevSection *nextPrev 112 113 // Menus 114 pageMenus *pageMenus 115 116 // Internal use 117 page.InternalDependencies 118 119 // The children. Regular pages will have none. 120 *pagePages 121 122 // Any bundled resources 123 resources resource.Resources 124 resourcesInit sync.Once 125 resourcesPublishInit sync.Once 126 127 translations page.Pages 128 allTranslations page.Pages 129 130 // Calculated an cached translation mapping key 131 translationKey string 132 translationKeyInit sync.Once 133 134 // Will only be set for bundled pages. 135 parent *pageState 136 137 // Set in fast render mode to force render a given page. 138 forceRender bool 139 } 140 141 func (p *pageCommon) Store() *maps.Scratch { 142 return p.store 143 } 144 145 type pagePages struct { 146 pagesInit sync.Once 147 pages page.Pages 148 149 regularPagesInit sync.Once 150 regularPages page.Pages 151 regularPagesRecursiveInit sync.Once 152 regularPagesRecursive page.Pages 153 }