mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-26 04:31:39 +03:00
Add OpenGraph helper module.
This commit is contained in:
parent
7ed754ab53
commit
2acf317245
46
examples/docs/src/OpenGraph.elm
Normal file
46
examples/docs/src/OpenGraph.elm
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
module OpenGraph exposing (website)
|
||||||
|
|
||||||
|
{-| <https://ogp.me/#>
|
||||||
|
-}
|
||||||
|
|
||||||
|
import Pages.Head as Head
|
||||||
|
|
||||||
|
|
||||||
|
{-| <https://ogp.me/#type_website>
|
||||||
|
-}
|
||||||
|
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)
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user