From 8cb5fa5dc36122d53a89530239d9036bc6594ffa Mon Sep 17 00:00:00 2001 From: Yoo Chung Date: Wed, 8 Mar 2023 22:14:13 -0500 Subject: [PATCH 1/2] Allow configuration of files to be checked for links. --- lib/Hakyll/Check.hs | 5 ++--- lib/Hakyll/Core/Configuration.hs | 12 +++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/Hakyll/Check.hs b/lib/Hakyll/Check.hs index dc167d17..dc72b87e 100644 --- a/lib/Hakyll/Check.hs +++ b/lib/Hakyll/Check.hs @@ -23,8 +23,7 @@ import Network.URI (unEscapeString) import System.Directory (doesDirectoryExist, doesFileExist) import System.Exit (ExitCode (..)) -import System.FilePath (takeDirectory, takeExtension, - ()) +import System.FilePath (takeDirectory, ()) import qualified Text.HTML.TagSoup as TS @@ -129,7 +128,7 @@ checkDestination = do let htmls = [ destinationDirectory config file | file <- files - , takeExtension file == ".html" + , checkHtmlFile config file ] forM_ htmls checkFile diff --git a/lib/Hakyll/Core/Configuration.hs b/lib/Hakyll/Core/Configuration.hs index 9d711232..35dc88d6 100644 --- a/lib/Hakyll/Core/Configuration.hs +++ b/lib/Hakyll/Core/Configuration.hs @@ -14,7 +14,8 @@ import Data.List (isPrefixOf, isSuffixOf) import qualified Network.Wai.Application.Static as Static import System.Directory (canonicalizePath) import System.Exit (ExitCode) -import System.FilePath (isAbsolute, normalise, takeFileName, makeRelative) +import System.FilePath (isAbsolute, makeRelative, normalise, + takeExtension, takeFileName) import System.IO.Error (catchIOError) import System.Process (system) @@ -47,6 +48,10 @@ data Configuration = Configuration -- want to use the test, you should use 'shouldIgnoreFile'. -- ignoreFile :: FilePath -> Bool + , -- | Function to determine HTML files whose links are to be checked. + -- + -- In 'defaultConfiguration', files with the @.html@ extension are checked. + checkHtmlFile :: FilePath -> Bool , -- | Function to determine files and directories that should not trigger -- a rebuild when touched in watch mode. -- @@ -88,9 +93,9 @@ data Configuration = Configuration -- One can also override the port as a command line argument: -- ./site preview -p 1234 previewPort :: Int - -- | Override other settings used by the preview server. Default is + , -- | Override other settings used by the preview server. Default is -- 'Static.defaultFileServerSettings'. - , previewSettings :: FilePath -> Static.StaticSettings + previewSettings :: FilePath -> Static.StaticSettings } -------------------------------------------------------------------------------- @@ -106,6 +111,7 @@ defaultConfiguration = Configuration , tmpDirectory = "_cache/tmp" , providerDirectory = "." , ignoreFile = ignoreFile' + , checkHtmlFile = (==) ".html" . takeExtension , watchIgnore = const False , deployCommand = "echo 'No deploy command specified' && exit 1" , deploySite = system . deployCommand From 268c8d303495cc08ec9eb1d68170c930aa5ef571 Mon Sep 17 00:00:00 2001 From: Yoo Chung Date: Mon, 3 Apr 2023 15:19:29 -0400 Subject: [PATCH 2/2] Reflect recently merged change of checking XHTML files. --- lib/Hakyll/Core/Configuration.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Hakyll/Core/Configuration.hs b/lib/Hakyll/Core/Configuration.hs index 35dc88d6..8e7ec392 100644 --- a/lib/Hakyll/Core/Configuration.hs +++ b/lib/Hakyll/Core/Configuration.hs @@ -111,7 +111,7 @@ defaultConfiguration = Configuration , tmpDirectory = "_cache/tmp" , providerDirectory = "." , ignoreFile = ignoreFile' - , checkHtmlFile = (==) ".html" . takeExtension + , checkHtmlFile = flip elem [".html", ".xhtml"] . takeExtension , watchIgnore = const False , deployCommand = "echo 'No deploy command specified' && exit 1" , deploySite = system . deployCommand