hugo

Fork of github.com/gohugoio/hugo with reverse pagination support

git clone git://git.shimmy1996.com/hugo.git

page_kinds.go (1388B)

    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
   15 
   16 import "strings"
   17 
   18 const (
   19 	KindPage = "page"
   20 
   21 	// The rest are node types; home page, sections etc.
   22 
   23 	KindHome    = "home"
   24 	KindSection = "section"
   25 
   26 	// Note tha before Hugo 0.73 these were confusingly named
   27 	// taxonomy (now: term)
   28 	// taxonomyTerm (now: taxonomy)
   29 	KindTaxonomy = "taxonomy"
   30 	KindTerm     = "term"
   31 )
   32 
   33 var kindMap = map[string]string{
   34 	strings.ToLower(KindPage):     KindPage,
   35 	strings.ToLower(KindHome):     KindHome,
   36 	strings.ToLower(KindSection):  KindSection,
   37 	strings.ToLower(KindTaxonomy): KindTaxonomy,
   38 	strings.ToLower(KindTerm):     KindTerm,
   39 
   40 	// Legacy, pre v0.53.0.
   41 	"taxonomyterm": KindTaxonomy,
   42 }
   43 
   44 // GetKind gets the page kind given a string, empty if not found.
   45 func GetKind(s string) string {
   46 	return kindMap[strings.ToLower(s)]
   47 }