Skip to content

Commit

Permalink
Allow configuration of files to be checked for links. (jaspervdj#973)
Browse files Browse the repository at this point in the history
* Allow configuration of files to be checked for links.

* Reflect recently merged change of checking XHTML files.
  • Loading branch information
chungyc authored Apr 4, 2023
1 parent 13b4697 commit 532eb3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/Hakyll/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -129,7 +128,7 @@ checkDestination = do
let htmls =
[ destinationDirectory config </> file
| file <- files
, takeExtension file `elem` [".html", ".xhtml"]
, checkHtmlFile config file
]

forM_ htmls checkFile
Expand Down
12 changes: 9 additions & 3 deletions lib/Hakyll/Core/Configuration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
--
Expand Down Expand Up @@ -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
}

--------------------------------------------------------------------------------
Expand All @@ -106,6 +111,7 @@ defaultConfiguration = Configuration
, tmpDirectory = "_cache/tmp"
, providerDirectory = "."
, ignoreFile = ignoreFile'
, checkHtmlFile = flip elem [".html", ".xhtml"] . takeExtension
, watchIgnore = const False
, deployCommand = "echo 'No deploy command specified' && exit 1"
, deploySite = system . deployCommand
Expand Down

0 comments on commit 532eb3b

Please sign in to comment.