page_nop.go (8443B)
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 page contains the core interfaces and types for the Page resource, 15 // a core component in Hugo. 16 package page 17 18 import ( 19 "html/template" 20 "time" 21 22 "github.com/gohugoio/hugo/identity" 23 24 "github.com/gohugoio/hugo/hugofs/files" 25 "github.com/gohugoio/hugo/tpl" 26 27 "github.com/gohugoio/hugo/hugofs" 28 29 "github.com/bep/gitmap" 30 "github.com/gohugoio/hugo/navigation" 31 32 "github.com/gohugoio/hugo/common/hugo" 33 "github.com/gohugoio/hugo/common/maps" 34 "github.com/gohugoio/hugo/source" 35 36 "github.com/gohugoio/hugo/config" 37 "github.com/gohugoio/hugo/langs" 38 "github.com/gohugoio/hugo/media" 39 "github.com/gohugoio/hugo/related" 40 "github.com/gohugoio/hugo/resources/resource" 41 ) 42 43 var ( 44 NopPage Page = new(nopPage) 45 NilPage *nopPage 46 ) 47 48 // PageNop implements Page, but does nothing. 49 type nopPage int 50 51 func (p *nopPage) Err() resource.ResourceError { 52 return nil 53 } 54 55 func (p *nopPage) Aliases() []string { 56 return nil 57 } 58 59 func (p *nopPage) Sitemap() config.Sitemap { 60 return config.Sitemap{} 61 } 62 63 func (p *nopPage) Layout() string { 64 return "" 65 } 66 67 func (p *nopPage) RSSLink() template.URL { 68 return "" 69 } 70 71 func (p *nopPage) Author() Author { 72 return Author{} 73 } 74 75 func (p *nopPage) Authors() AuthorList { 76 return nil 77 } 78 79 func (p *nopPage) AllTranslations() Pages { 80 return nil 81 } 82 83 func (p *nopPage) LanguagePrefix() string { 84 return "" 85 } 86 87 func (p *nopPage) AlternativeOutputFormats() OutputFormats { 88 return nil 89 } 90 91 func (p *nopPage) BaseFileName() string { 92 return "" 93 } 94 95 func (p *nopPage) BundleType() files.ContentClass { 96 return "" 97 } 98 99 func (p *nopPage) Content() (any, error) { 100 return "", nil 101 } 102 103 func (p *nopPage) ContentBaseName() string { 104 return "" 105 } 106 107 func (p *nopPage) CurrentSection() Page { 108 return nil 109 } 110 111 func (p *nopPage) Data() any { 112 return nil 113 } 114 115 func (p *nopPage) Date() (t time.Time) { 116 return 117 } 118 119 func (p *nopPage) Description() string { 120 return "" 121 } 122 123 func (p *nopPage) RefFrom(argsm map[string]any, source any) (string, error) { 124 return "", nil 125 } 126 127 func (p *nopPage) RelRefFrom(argsm map[string]any, source any) (string, error) { 128 return "", nil 129 } 130 131 func (p *nopPage) Dir() string { 132 return "" 133 } 134 135 func (p *nopPage) Draft() bool { 136 return false 137 } 138 139 func (p *nopPage) Eq(other any) bool { 140 return p == other 141 } 142 143 func (p *nopPage) ExpiryDate() (t time.Time) { 144 return 145 } 146 147 func (p *nopPage) Ext() string { 148 return "" 149 } 150 151 func (p *nopPage) Extension() string { 152 return "" 153 } 154 155 var nilFile *source.FileInfo 156 157 func (p *nopPage) File() source.File { 158 return nilFile 159 } 160 161 func (p *nopPage) FileInfo() hugofs.FileMetaInfo { 162 return nil 163 } 164 165 func (p *nopPage) Filename() string { 166 return "" 167 } 168 169 func (p *nopPage) FirstSection() Page { 170 return nil 171 } 172 173 func (p *nopPage) FuzzyWordCount() int { 174 return 0 175 } 176 177 func (p *nopPage) GetPage(ref string) (Page, error) { 178 return nil, nil 179 } 180 181 func (p *nopPage) GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, error) { 182 return nil, nil 183 } 184 185 func (p *nopPage) GetParam(key string) any { 186 return nil 187 } 188 189 func (p *nopPage) GetTerms(taxonomy string) Pages { 190 return nil 191 } 192 193 func (p *nopPage) GitInfo() *gitmap.GitInfo { 194 return nil 195 } 196 197 func (p *nopPage) CodeOwners() []string { 198 return nil 199 } 200 201 func (p *nopPage) HasMenuCurrent(menuID string, me *navigation.MenuEntry) bool { 202 return false 203 } 204 205 func (p *nopPage) HasShortcode(name string) bool { 206 return false 207 } 208 209 func (p *nopPage) Hugo() (h hugo.Info) { 210 return 211 } 212 213 func (p *nopPage) InSection(other any) (bool, error) { 214 return false, nil 215 } 216 217 func (p *nopPage) IsAncestor(other any) (bool, error) { 218 return false, nil 219 } 220 221 func (p *nopPage) IsDescendant(other any) (bool, error) { 222 return false, nil 223 } 224 225 func (p *nopPage) IsDraft() bool { 226 return false 227 } 228 229 func (p *nopPage) IsHome() bool { 230 return false 231 } 232 233 func (p *nopPage) IsMenuCurrent(menuID string, inme *navigation.MenuEntry) bool { 234 return false 235 } 236 237 func (p *nopPage) IsNode() bool { 238 return false 239 } 240 241 func (p *nopPage) IsPage() bool { 242 return false 243 } 244 245 func (p *nopPage) IsSection() bool { 246 return false 247 } 248 249 func (p *nopPage) IsTranslated() bool { 250 return false 251 } 252 253 func (p *nopPage) Keywords() []string { 254 return nil 255 } 256 257 func (p *nopPage) Kind() string { 258 return "" 259 } 260 261 func (p *nopPage) Lang() string { 262 return "" 263 } 264 265 func (p *nopPage) Language() *langs.Language { 266 return nil 267 } 268 269 func (p *nopPage) Lastmod() (t time.Time) { 270 return 271 } 272 273 func (p *nopPage) Len() int { 274 return 0 275 } 276 277 func (p *nopPage) LinkTitle() string { 278 return "" 279 } 280 281 func (p *nopPage) LogicalName() string { 282 return "" 283 } 284 285 func (p *nopPage) MediaType() (m media.Type) { 286 return 287 } 288 289 func (p *nopPage) Menus() (m navigation.PageMenus) { 290 return 291 } 292 293 func (p *nopPage) Name() string { 294 return "" 295 } 296 297 func (p *nopPage) Next() Page { 298 return nil 299 } 300 301 func (p *nopPage) OutputFormats() OutputFormats { 302 return nil 303 } 304 305 func (p *nopPage) Pages() Pages { 306 return nil 307 } 308 309 func (p *nopPage) RegularPages() Pages { 310 return nil 311 } 312 313 func (p *nopPage) RegularPagesRecursive() Pages { 314 return nil 315 } 316 317 func (p *nopPage) Paginate(seq any, options ...any) (*Pager, error) { 318 return nil, nil 319 } 320 321 func (p *nopPage) Paginator(options ...any) (*Pager, error) { 322 return nil, nil 323 } 324 325 func (p *nopPage) Param(key any) (any, error) { 326 return nil, nil 327 } 328 329 func (p *nopPage) Params() maps.Params { 330 return nil 331 } 332 333 func (p *nopPage) Page() Page { 334 return p 335 } 336 337 func (p *nopPage) Parent() Page { 338 return nil 339 } 340 341 func (p *nopPage) Path() string { 342 return "" 343 } 344 345 func (p *nopPage) Pathc() string { 346 return "" 347 } 348 349 func (p *nopPage) Permalink() string { 350 return "" 351 } 352 353 func (p *nopPage) Plain() string { 354 return "" 355 } 356 357 func (p *nopPage) PlainWords() []string { 358 return nil 359 } 360 361 func (p *nopPage) Prev() Page { 362 return nil 363 } 364 365 func (p *nopPage) PublishDate() (t time.Time) { 366 return 367 } 368 369 func (p *nopPage) PrevInSection() Page { 370 return nil 371 } 372 373 func (p *nopPage) NextInSection() Page { 374 return nil 375 } 376 377 func (p *nopPage) PrevPage() Page { 378 return nil 379 } 380 381 func (p *nopPage) NextPage() Page { 382 return nil 383 } 384 385 func (p *nopPage) RawContent() string { 386 return "" 387 } 388 389 func (p *nopPage) ReadingTime() int { 390 return 0 391 } 392 393 func (p *nopPage) Ref(argsm map[string]any) (string, error) { 394 return "", nil 395 } 396 397 func (p *nopPage) RelPermalink() string { 398 return "" 399 } 400 401 func (p *nopPage) RelRef(argsm map[string]any) (string, error) { 402 return "", nil 403 } 404 405 func (p *nopPage) Render(layout ...string) (template.HTML, error) { 406 return "", nil 407 } 408 409 func (p *nopPage) RenderString(args ...any) (template.HTML, error) { 410 return "", nil 411 } 412 413 func (p *nopPage) ResourceType() string { 414 return "" 415 } 416 417 func (p *nopPage) Resources() resource.Resources { 418 return nil 419 } 420 421 func (p *nopPage) Scratch() *maps.Scratch { 422 return nil 423 } 424 425 func (p *nopPage) Store() *maps.Scratch { 426 return nil 427 } 428 429 func (p *nopPage) RelatedKeywords(cfg related.IndexConfig) ([]related.Keyword, error) { 430 return nil, nil 431 } 432 433 func (p *nopPage) Section() string { 434 return "" 435 } 436 437 func (p *nopPage) Sections() Pages { 438 return nil 439 } 440 441 func (p *nopPage) SectionsEntries() []string { 442 return nil 443 } 444 445 func (p *nopPage) SectionsPath() string { 446 return "" 447 } 448 449 func (p *nopPage) Site() Site { 450 return nil 451 } 452 453 func (p *nopPage) Sites() Sites { 454 return nil 455 } 456 457 func (p *nopPage) Slug() string { 458 return "" 459 } 460 461 func (p *nopPage) String() string { 462 return "nopPage" 463 } 464 465 func (p *nopPage) Summary() template.HTML { 466 return "" 467 } 468 469 func (p *nopPage) TableOfContents() template.HTML { 470 return "" 471 } 472 473 func (p *nopPage) Title() string { 474 return "" 475 } 476 477 func (p *nopPage) TranslationBaseName() string { 478 return "" 479 } 480 481 func (p *nopPage) TranslationKey() string { 482 return "" 483 } 484 485 func (p *nopPage) Translations() Pages { 486 return nil 487 } 488 489 func (p *nopPage) Truncated() bool { 490 return false 491 } 492 493 func (p *nopPage) Type() string { 494 return "" 495 } 496 497 func (p *nopPage) URL() string { 498 return "" 499 } 500 501 func (p *nopPage) UniqueID() string { 502 return "" 503 } 504 505 func (p *nopPage) Weight() int { 506 return 0 507 } 508 509 func (p *nopPage) WordCount() int { 510 return 0 511 } 512 513 func (p *nopPage) GetIdentity() identity.Identity { 514 return identity.NewPathIdentity("content", "foo/bar.md") 515 }