github.com/graemephi/kahugo@v0.62.3-0.20211121071557-d78c0423784d/hugolib/page_kinds.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  	"strings"
    18  
    19  	"github.com/gohugoio/hugo/resources/page"
    20  )
    21  
    22  // This is all the kinds we can expect to find in .Site.Pages.
    23  var allKindsInPages = []string{page.KindPage, page.KindHome, page.KindSection, page.KindTerm, page.KindTaxonomy}
    24  
    25  const (
    26  
    27  	// Temporary state.
    28  	kindUnknown = "unknown"
    29  
    30  	// The following are (currently) temporary nodes,
    31  	// i.e. nodes we create just to render in isolation.
    32  	kindRSS       = "RSS"
    33  	kindSitemap   = "sitemap"
    34  	kindRobotsTXT = "robotsTXT"
    35  	kind404       = "404"
    36  
    37  	pageResourceType = "page"
    38  )
    39  
    40  var kindMap = map[string]string{
    41  	strings.ToLower(kindRSS):       kindRSS,
    42  	strings.ToLower(kindSitemap):   kindSitemap,
    43  	strings.ToLower(kindRobotsTXT): kindRobotsTXT,
    44  	strings.ToLower(kind404):       kind404,
    45  }
    46  
    47  func getKind(s string) string {
    48  	if pkind := page.GetKind(s); pkind != "" {
    49  		return pkind
    50  	}
    51  	return kindMap[strings.ToLower(s)]
    52  }