mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-09-11 09:05:28 +03:00
Update hacker news SEO tags.
This commit is contained in:
parent
e6c65bbdf2
commit
4f0a604d7f
@ -9,7 +9,6 @@ import Head.Seo as Seo
|
||||
import Html exposing (Html)
|
||||
import Html.Attributes as Attr
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (required)
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Path exposing (Path)
|
||||
@ -131,12 +130,6 @@ data routeParams =
|
||||
getStories =
|
||||
DataSource.Http.get getStoriesUrl
|
||||
(Story.decoder |> Json.Decode.list)
|
||||
|
||||
--("https://node-hnapi.herokuapp.com/"
|
||||
-- ++ feed
|
||||
-- ++ "?page="
|
||||
--)
|
||||
--get(`https://node-hnapi.herokuapp.com/${l}?page=${page}`);
|
||||
in
|
||||
getStories |> DataSource.map (\stories -> Response.render { stories = stories, currentPage = currentPage })
|
||||
)
|
||||
@ -148,20 +141,29 @@ head :
|
||||
head static =
|
||||
Seo.summary
|
||||
{ canonicalUrlOverride = Nothing
|
||||
, siteName = "elm-pages"
|
||||
, siteName = "elm-pages Hacker News"
|
||||
, image =
|
||||
{ url = Pages.Url.external "TODO"
|
||||
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
|
||||
, alt = "elm-pages logo"
|
||||
, dimensions = Nothing
|
||||
, mimeType = Nothing
|
||||
}
|
||||
, description = "TODO"
|
||||
, description = "A demo of elm-pages 3 server-rendered routes."
|
||||
, locale = Nothing
|
||||
, title = "TODO title" -- metadata.title -- TODO
|
||||
, title = title static.routeParams
|
||||
}
|
||||
|> Seo.website
|
||||
|
||||
|
||||
title : RouteParams -> String
|
||||
title routeParams =
|
||||
(routeParams.feed
|
||||
|> Maybe.map (\feedName -> feedName ++ " | ")
|
||||
|> Maybe.withDefault ""
|
||||
)
|
||||
++ "elm-pages Hacker News"
|
||||
|
||||
|
||||
view :
|
||||
Maybe PageUrl
|
||||
-> Shared.Model
|
||||
@ -169,7 +171,7 @@ view :
|
||||
-> StaticPayload Data RouteParams
|
||||
-> View Msg
|
||||
view maybeUrl sharedModel model static =
|
||||
{ title = "News"
|
||||
{ title = title static.routeParams
|
||||
, body =
|
||||
[ paginationView static.data.stories static.routeParams static.data.currentPage
|
||||
, Html.main_
|
||||
|
@ -8,6 +8,7 @@ import Head
|
||||
import Head.Seo as Seo
|
||||
import Html exposing (Html)
|
||||
import Html.Attributes as Attr
|
||||
import Html.Keyed
|
||||
import Json.Decode as Decode
|
||||
import Json.Encode as Encode
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
@ -106,16 +107,16 @@ head :
|
||||
head static =
|
||||
Seo.summary
|
||||
{ canonicalUrlOverride = Nothing
|
||||
, siteName = "elm-pages"
|
||||
, siteName = "elm-pages Hacker News"
|
||||
, image =
|
||||
{ url = Pages.Url.external "TODO"
|
||||
{ url = [ "images", "icon-png.png" ] |> Path.join |> Pages.Url.fromPath
|
||||
, alt = "elm-pages logo"
|
||||
, dimensions = Nothing
|
||||
, mimeType = Nothing
|
||||
}
|
||||
, description = "TODO"
|
||||
, description = "A demo of elm-pages 3 server-rendered routes."
|
||||
, locale = Nothing
|
||||
, title = "TODO title" -- metadata.title -- TODO
|
||||
, title = static.data.story |> Tuple.first |> (\(Item common _) -> common.title)
|
||||
}
|
||||
|> Seo.website
|
||||
|
||||
@ -127,7 +128,7 @@ view :
|
||||
-> StaticPayload Data RouteParams
|
||||
-> View Msg
|
||||
view maybeUrl sharedModel model static =
|
||||
{ title = "Story"
|
||||
{ title = static.data.story |> Tuple.first |> (\(Item common _) -> common.title)
|
||||
, body =
|
||||
[ storyView static.data.story
|
||||
]
|
||||
@ -186,16 +187,16 @@ storyView ( Item story entry, commentsJson ) =
|
||||
else
|
||||
Html.text "No comments yet."
|
||||
]
|
||||
, Html.ul
|
||||
, Html.Keyed.ul
|
||||
[ Attr.class "comment-children"
|
||||
]
|
||||
((commentsJson
|
||||
|> Decode.decodeString (Decode.list Decode.value)
|
||||
|> Result.withDefault []
|
||||
)
|
||||
|> List.map
|
||||
(\comment ->
|
||||
Html.node "news-comment" [ Attr.property "commentBody" comment ] []
|
||||
|> List.indexedMap
|
||||
(\index comment ->
|
||||
( String.fromInt index, Html.node "news-comment" [ Attr.property "commentBody" comment ] [] )
|
||||
)
|
||||
)
|
||||
]
|
||||
|
BIN
examples/hackernews/public/images/icon-png.png
Normal file
BIN
examples/hackernews/public/images/icon-png.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 976 B |
Loading…
Reference in New Issue
Block a user