mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-26 04:31:39 +03:00
Extract out common type.
This commit is contained in:
parent
bc590bbf0e
commit
44e08be4d9
@ -31,8 +31,8 @@ buildCommon builder =
|
|||||||
website :
|
website :
|
||||||
Common
|
Common
|
||||||
-> List Head.Tag
|
-> List Head.Tag
|
||||||
website details =
|
website common =
|
||||||
Website details |> tags
|
Website |> Content common |> tags
|
||||||
|
|
||||||
|
|
||||||
{-| See <https://ogp.me/#type_article>
|
{-| See <https://ogp.me/#type_article>
|
||||||
@ -48,7 +48,7 @@ article :
|
|||||||
}
|
}
|
||||||
-> List Head.Tag
|
-> List Head.Tag
|
||||||
article common details =
|
article common details =
|
||||||
Article common details |> tags
|
Article details |> Content common |> tags
|
||||||
|
|
||||||
|
|
||||||
{-| See <https://ogp.me/#type_book>
|
{-| See <https://ogp.me/#type_book>
|
||||||
@ -62,7 +62,7 @@ book :
|
|||||||
}
|
}
|
||||||
-> List Head.Tag
|
-> List Head.Tag
|
||||||
book common details =
|
book common details =
|
||||||
Book common details |> tags
|
Book details |> Content common |> tags
|
||||||
|
|
||||||
|
|
||||||
{-| These fields apply to any type in the og object types
|
{-| These fields apply to any type in the og object types
|
||||||
@ -134,9 +134,12 @@ type alias Locale =
|
|||||||
|
|
||||||
|
|
||||||
type Content
|
type Content
|
||||||
= Website Common
|
= Content Common ContentDetails
|
||||||
|
|
||||||
|
|
||||||
|
type ContentDetails
|
||||||
|
= Website
|
||||||
| Article
|
| Article
|
||||||
Common
|
|
||||||
{ tags : List String
|
{ tags : List String
|
||||||
, section : Maybe String
|
, section : Maybe String
|
||||||
, publishedTime : Maybe Iso8601DateTime
|
, publishedTime : Maybe Iso8601DateTime
|
||||||
@ -144,7 +147,6 @@ type Content
|
|||||||
, expirationTime : Maybe Iso8601DateTime
|
, expirationTime : Maybe Iso8601DateTime
|
||||||
}
|
}
|
||||||
| Book
|
| Book
|
||||||
Common
|
|
||||||
{ tags : List String
|
{ tags : List String
|
||||||
, isbn : Maybe String
|
, isbn : Maybe String
|
||||||
, releaseDate : Maybe Iso8601DateTime
|
, releaseDate : Maybe Iso8601DateTime
|
||||||
@ -156,7 +158,6 @@ type Content
|
|||||||
music:album - music.album array - The album this song is from.
|
music:album - music.album array - The album this song is from.
|
||||||
music:musician - profile array - The musician that made this song.
|
music:musician - profile array - The musician that made this song.
|
||||||
-}
|
-}
|
||||||
Common
|
|
||||||
{ duration : Maybe Int
|
{ duration : Maybe Int
|
||||||
, album : Maybe Int
|
, album : Maybe Int
|
||||||
, disc : Maybe Int
|
, disc : Maybe Int
|
||||||
@ -219,47 +220,44 @@ tagsForVideo video =
|
|||||||
|
|
||||||
|
|
||||||
tags : Content -> List Head.Tag
|
tags : Content -> List Head.Tag
|
||||||
tags content =
|
tags (Content common details) =
|
||||||
(case content of
|
tagsForCommon common
|
||||||
Website common ->
|
++ (case details of
|
||||||
tagsForCommon common
|
Website ->
|
||||||
++ [ ( "og:type", Just "website" )
|
[ ( "og:type", Just "website" )
|
||||||
]
|
]
|
||||||
|
|
||||||
Article common details ->
|
Article articleDetails ->
|
||||||
{-
|
{-
|
||||||
TODO
|
TODO
|
||||||
- article:author - profile array - Writers of the article.
|
- article:author - profile array - Writers of the article.
|
||||||
-}
|
-}
|
||||||
tagsForCommon common
|
[ ( "og:type", Just "article" )
|
||||||
++ [ ( "og:type", Just "article" )
|
, ( "article:section", articleDetails.section )
|
||||||
, ( "article:section", details.section )
|
, ( "article:published_time", articleDetails.publishedTime )
|
||||||
, ( "article:published_time", details.publishedTime )
|
, ( "article:modified_time", articleDetails.modifiedTime )
|
||||||
, ( "article:modified_time", details.modifiedTime )
|
, ( "article:expiration_time", articleDetails.expirationTime )
|
||||||
, ( "article:expiration_time", details.expirationTime )
|
]
|
||||||
]
|
++ List.map
|
||||||
++ List.map
|
(\tag -> ( "article:tag", tag |> Just ))
|
||||||
(\tag -> ( "article:tag", tag |> Just ))
|
articleDetails.tags
|
||||||
details.tags
|
|
||||||
|
|
||||||
Book common details ->
|
Book bookDetails ->
|
||||||
tagsForCommon common
|
[ ( "og:type", Just "book" )
|
||||||
++ [ ( "og:type", Just "book" )
|
, ( "og:isbn", bookDetails.isbn )
|
||||||
, ( "og:isbn", details.isbn )
|
, ( "og:release_date", bookDetails.releaseDate )
|
||||||
, ( "og:release_date", details.releaseDate )
|
]
|
||||||
]
|
++ List.map
|
||||||
++ List.map
|
(\tag -> ( "book:tag", tag |> Just ))
|
||||||
(\tag -> ( "book:tag", tag |> Just ))
|
bookDetails.tags
|
||||||
details.tags
|
|
||||||
|
|
||||||
Song common details ->
|
Song songDetails ->
|
||||||
tagsForCommon common
|
[ ( "og:type", Just "music.song" )
|
||||||
++ [ ( "og:type", Just "music.song" )
|
, ( "music:duration", songDetails.duration |> Maybe.map String.fromInt )
|
||||||
, ( "music:duration", details.duration |> Maybe.map String.fromInt )
|
, ( "music:album:disc", songDetails.disc |> Maybe.map String.fromInt )
|
||||||
, ( "music:album:disc", details.disc |> Maybe.map String.fromInt )
|
, ( "music:album:track", songDetails.track |> Maybe.map String.fromInt )
|
||||||
, ( "music:album:track", details.track |> Maybe.map String.fromInt )
|
]
|
||||||
]
|
)
|
||||||
)
|
|
||||||
|> List.filterMap
|
|> List.filterMap
|
||||||
(\( name, maybeContent ) ->
|
(\( name, maybeContent ) ->
|
||||||
maybeContent
|
maybeContent
|
||||||
|
Loading…
Reference in New Issue
Block a user