diff --git a/examples/docs/src/OpenGraph.elm b/examples/docs/src/OpenGraph.elm new file mode 100644 index 00000000..81cc2ef1 --- /dev/null +++ b/examples/docs/src/OpenGraph.elm @@ -0,0 +1,46 @@ +module OpenGraph exposing (website) + +{-| +-} + +import Pages.Head as Head + + +{-| +-} +website : + { url : String + , name : String + , imageUrl : Maybe String + } + -> List Head.Tag +website details = + Website details + |> tags + + +type Content + = Website + { url : String + , name : String + , imageUrl : Maybe String + } + + +tags content = + case content of + Website details -> + [ ( "og:type", Just "website" ) + , ( "og:url", Just details.url ) + , ( "og:locale", Just "en" ) + , ( "og:site_name", Just details.name ) + , ( "og:image", details.imageUrl ) + + -- , ( "og:image:width", Just "512" ) + -- , ( "og:image:height", Just "512" ) + ] + |> List.filterMap + (\( name, maybeContent ) -> + maybeContent + |> Maybe.map (\metaContent -> Head.metaName name metaContent) + )