Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of files to be checked for links. #973

Merged
merged 3 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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