Verified Commit be3d0148 authored by doshitan's avatar doshitan

Add more error pages

parent 9f48bec2
<h1>$status-msg$ - $code$</h1>
$if(body)$
<p>$body$</p>
$endif$
<pre>
|\ _,,,---,,_
ZZZzz /,`.-'`' -. ;-;;,_
|,4- ) )-,_. ,\ ( `'-'
'---''(_/--' `-'\_)
</pre>
......@@ -30,6 +30,7 @@ executable site
, directory
, filepath
, hakyll
, http-types
, pandoc
, pandoc-sidenote
, pandoc-types
......
......@@ -3,6 +3,7 @@ import qualified Data.Text.IO as TIO
import Hakyll
import Hakyll.Core.Compiler.Internal (compilerAsk, compilerProvider)
import Hakyll.Core.Provider (resourceFilePath)
import Network.HTTP.Types.Status
import RIO
import RIO.FilePath (takeBaseName, takeDirectory)
import qualified RIO.HashMap as HM
......@@ -256,12 +257,18 @@ main = do
compileFeed "All posts" "posts/*" tags
-- custom error pages
for_ [(404, "Oops, could not find that page.")] $ \(code, msg) -> do
create [fromString (show code ++ ".html")] $ do
for_ [ (badRequest400, Nothing)
, (forbidden403, Nothing)
, (notFound404, Just "Oops, could not find that page. Maybe try the search to find what you were looking for.")
, (methodNotAllowed405, Nothing)
, (status500, Nothing)
] $ \(status, mMsg) -> do
create [fromString (show (statusCode status) ++ ".html")] $ do
route idRoute
compile $ do
let ctx = mconcat [ constField "code" (show code)
, constField "body" msg
let ctx = mconcat [ constField "code" (show $ statusCode status)
, constField "status-msg" (T.unpack . T.decodeUtf8With T.lenientDecode $ statusMessage status)
, foldMap (constField "body") mMsg
, baseCtx
]
makeItem ""
......
......@@ -163,11 +163,36 @@ resource "aws_cloudfront_distribution" "site_distribution" {
}
}
custom_error_response {
error_code = 400
response_code = 400
response_page_path = "/400.html"
}
custom_error_response {
error_code = 403
response_code = 403
response_page_path = "/403.html"
}
custom_error_response {
error_code = 404
response_code = 404
response_page_path = "/404.html"
}
custom_error_response {
error_code = 405
response_code = 405
response_page_path = "/405.html"
}
custom_error_response {
error_code = 500
response_code = 500
response_page_path = "/500.html"
}
viewer_certificate {
# TODO: use resource to generate this
# acm_certificate_arn = "${aws_acm_certificate.cert.arn}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment