Create open graph meta tag helper.

This commit is contained in:
Dillon Kearns 2019-08-05 10:32:10 -07:00
parent 2acf317245
commit b2e58c7a95
2 changed files with 21 additions and 20 deletions

View File

@ -13,6 +13,7 @@ import Mark.Error
import MarkParser
import Markdown
import Metadata exposing (Metadata)
import OpenGraph
import Pages
import Pages.Content as Content exposing (Content)
import Pages.Head as Head
@ -158,24 +159,28 @@ header =
head : String -> Metadata.Metadata msg -> List Head.Tag
head canonicalUrl metadata =
let
siteName =
"A statically typed site generator - elm-pages"
themeColor =
"#ffffff"
in
[ Head.metaName "theme-color" themeColor
, Head.metaProperty "og:site_name" siteName
, Head.metaProperty "og:url" canonicalUrl
, Head.canonicalLink canonicalUrl
]
++ pageTags metadata
++ pageTags canonicalUrl metadata
pageTags metadata =
siteTagline =
"A statically typed site generator - elm-pages"
pageTags canonicalUrl metadata =
case metadata of
Metadata.Page record ->
[]
OpenGraph.website
{ url = canonicalUrl
, name = "elm-pages"
, imageUrl = ""
, description = Just siteTagline
}
Metadata.Article meta ->
let
@ -188,15 +193,11 @@ pageTags metadata =
image =
""
in
[ Head.metaProperty "og:title" title
, Head.metaName "description" description
, Head.metaProperty "og:description" description
, Head.metaProperty "og:image" image
[ Head.metaName "description" description
, Head.metaName "image" image
, Head.metaProperty "og:type" "article"
]
++ SocialMeta.summaryLarge
{ title = ""
{ title = meta.title.raw
, description = Just description
, siteUser = Nothing
, image = Just { url = image, alt = description }

View File

@ -11,7 +11,8 @@ import Pages.Head as Head
website :
{ url : String
, name : String
, imageUrl : Maybe String
, imageUrl : String
, description : Maybe String
}
-> List Head.Tag
website details =
@ -23,7 +24,8 @@ type Content
= Website
{ url : String
, name : String
, imageUrl : Maybe String
, imageUrl : String
, description : Maybe String
}
@ -34,10 +36,8 @@ tags content =
, ( "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" )
, ( "og:image", Just details.imageUrl )
, ( "og:description", details.description )
]
|> List.filterMap
(\( name, maybeContent ) ->