From 2acf3172454045cb9e730c1779d51683368d9617 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Mon, 5 Aug 2019 10:21:02 -0700 Subject: [PATCH] Add OpenGraph helper module. --- examples/docs/src/OpenGraph.elm | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 examples/docs/src/OpenGraph.elm 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) + )