Move the schema.org/BreadcrumbList stuff out of Foundation
This commit is contained in:
parent
a880e66c31
commit
5a83121431
2 changed files with 24 additions and 18 deletions
21
src/SchemaOrg/BreadcrumbList.hs
Normal file
21
src/SchemaOrg/BreadcrumbList.hs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{-# LANGUAGE OverloadedStrings #-}
|
||||
module SchemaOrg.BreadcrumbList ( breadcrumbList ) where
|
||||
|
||||
import Data.Aeson
|
||||
import qualified Data.Text as T
|
||||
|
||||
breadcrumbList :: [(a, T.Text)] -> (a -> [(T.Text, T.Text)] -> T.Text) -> Value
|
||||
breadcrumbList crumbs url = object
|
||||
[ ("@context", "http://schema.org")
|
||||
, ("@type", "BreadcrumbList")
|
||||
, "itemListElement" .= zipWith (listItem url) [1 :: Int ..] crumbs
|
||||
]
|
||||
listItem :: (a -> [(T.Text, T.Text)] -> T.Text) -> Int -> (a, T.Text) -> Value
|
||||
listItem url i (r, t) = object
|
||||
[ ("@type", "ListItem")
|
||||
, "position" .= i
|
||||
, "item" .= object
|
||||
[ "@id" .= url r []
|
||||
, "name" .= t
|
||||
]
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue