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