Mark up entry permalink pages with OpenGraph garbage too

This commit is contained in:
Danielle McLean 2017-10-14 17:09:27 +11:00
parent 47fe00a8b8
commit 2956550a6c
Signed by: 00dani
GPG key ID: 5A5D2D1AFF12EEC5
4 changed files with 14 additions and 1 deletions

View file

@ -264,3 +264,7 @@ unsafeHandler = Unsafe.fakeHandlerGetLogger appLogger
-- https://github.com/yesodweb/yesod/wiki/Sending-email
-- https://github.com/yesodweb/yesod/wiki/Serve-static-files-from-a-separate-domain
-- https://github.com/yesodweb/yesod/wiki/i18n-messages-in-the-scaffolding
userProfile :: User -> Route App
userProfile user
| userUsername user == siteUsername compileTimeAppSettings = HomeR
| otherwise = error "Multiple profile pages are not yet supported"

View file

@ -1,4 +1,5 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}
module Handler.Entries where
@ -33,8 +34,16 @@ renderEntry :: (Entity Entry) -> Handler Html
renderEntry entry = do
let correctRoute = entryR entry
actualRoute <- getCurrentRoute
author <- getCached . entryAuthorId $ entityVal entry
when (actualRoute /= Just correctRoute) $
redirectWith movedPermanently301 correctRoute
defaultLayout $ do
setTitle . toHtml . entryTitle . entityVal $ entry
toWidgetHead [hamlet|
<meta property="og:title" content=#{entryTitle $ entityVal entry}>
<meta property="og:type" content="article">
<meta property="og:description" content=#{entryContent $ entityVal entry}>
<meta property="article:author" content=@{userProfile $ entityVal author}>
<meta property="article:section" content=#{K.pluralise $ entryKind $ entityVal entry}>
|]
hEntry entry

View file

@ -39,6 +39,7 @@ hCard (Entity userId user) = do
<meta name="author" content=#{userFullName user}>
<link rel="author" href=@{HomeR}>
<meta property="og:type" content="profile">
<meta property="og:title" content="#{userFullName user}">
<meta property="og:description" content=#{userNote user}>
<meta property="og:image" content=@{staticR ["img", userAvatar user]}>
<meta property="profile:first_name" content=#{firstName}>

View file

@ -6,7 +6,6 @@ $doctype 5
<meta name="generator" content="#{packageName package} #{packageVersion package}">
<title>#{fullTitle}
<meta property="og:title" content=#{fullTitle}>
$maybe route <- mcurrentRoute
<link rel="canonical" href=@{route}>
<meta property="og:url" content=@{route}>