diff options
-rw-r--r-- | hakyll.cabal | 2 | ||||
-rw-r--r-- | src/Hakyll/Core/Routes.hs | 18 | ||||
-rw-r--r-- | tests/Hakyll/Core/Routes/Tests.hs | 12 | ||||
-rw-r--r-- | tests/data/example.md.metadata | 1 | ||||
-rw-r--r-- | web/examples.markdown | 2 | ||||
-rw-r--r-- | web/releases.markdown | 4 |
6 files changed, 31 insertions, 8 deletions
diff --git a/hakyll.cabal b/hakyll.cabal index 001ee0e..293868b 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.4.2.0 +Version: 4.4.3.0 Synopsis: A static website compiler library Description: diff --git a/src/Hakyll/Core/Routes.hs b/src/Hakyll/Core/Routes.hs index 34a613d..470d727 100644 --- a/src/Hakyll/Core/Routes.hs +++ b/src/Hakyll/Core/Routes.hs @@ -61,9 +61,16 @@ type UsedMetadata = Bool -------------------------------------------------------------------------------- +data RoutesRead = RoutesRead + { routesProvider :: Provider + , routesUnderlying :: Identifier + } + + +-------------------------------------------------------------------------------- -- | Type used for a route newtype Routes = Routes - { unRoutes :: Provider -> Identifier -> IO (Maybe FilePath, UsedMetadata) + { unRoutes :: RoutesRead -> Identifier -> IO (Maybe FilePath, UsedMetadata) } @@ -81,7 +88,8 @@ instance Monoid Routes where -- | Apply a route to an identifier runRoutes :: Routes -> Provider -> Identifier -> IO (Maybe FilePath, UsedMetadata) -runRoutes = unRoutes +runRoutes routes provider identifier = + unRoutes routes (RoutesRead provider identifier) identifier -------------------------------------------------------------------------------- @@ -156,9 +164,9 @@ gsubRoute pattern replacement = customRoute $ -------------------------------------------------------------------------------- -- | Get access to the metadata in order to determine the route metadataRoute :: (Metadata -> Routes) -> Routes -metadataRoute f = Routes $ \p i -> do - metadata <- resourceMetadata p i - unRoutes (f metadata) p i +metadataRoute f = Routes $ \r i -> do + metadata <- resourceMetadata (routesProvider r) (routesUnderlying r) + unRoutes (f metadata) r i -------------------------------------------------------------------------------- diff --git a/tests/Hakyll/Core/Routes/Tests.hs b/tests/Hakyll/Core/Routes/Tests.hs index c681c99..4f975ae 100644 --- a/tests/Hakyll/Core/Routes/Tests.hs +++ b/tests/Hakyll/Core/Routes/Tests.hs @@ -6,6 +6,8 @@ module Hakyll.Core.Routes.Tests -------------------------------------------------------------------------------- +import qualified Data.Map as M +import System.FilePath ((</>)) import Test.Framework (Test, testGroup) import Test.HUnit (Assertion, (@=?)) @@ -33,12 +35,18 @@ tests = testGroup "Hakyll.Core.Routes.Tests" $ fromAssertions "runRoutes" , testRoutes "tags/bar.xml" (gsubRoute "rss/" (const "") `composeRoutes` setExtension "xml") "tags/rss/bar" + + , testRoutes "food/example.md" (metadataRoute $ \md -> customRoute $ \id' -> + M.findWithDefault "?" "subblog" md </> toFilePath id') + "example.md" ] -------------------------------------------------------------------------------- testRoutes :: FilePath -> Routes -> Identifier -> Assertion testRoutes expected r id' = do - (route, _) <- runRoutes r - (error "Hakyll.Core.Routes.Tests: no provider") id' + store <- newTestStore + provider <- newTestProvider store + (route, _) <- runRoutes r provider id' Just expected @=? route + cleanTestEnv diff --git a/tests/data/example.md.metadata b/tests/data/example.md.metadata index 9685918..5d463ae 100644 --- a/tests/data/example.md.metadata +++ b/tests/data/example.md.metadata @@ -1,2 +1,3 @@ external: External data date: 2012-10-22 14:35:24 +subblog: food diff --git a/web/examples.markdown b/web/examples.markdown index 4c38a82..bf5572e 100644 --- a/web/examples.markdown +++ b/web/examples.markdown @@ -71,6 +71,8 @@ this list. This list has no particular ordering. [source](https://github.com/rosedu/techblog) - <http://abizern.org>, [source](https://github.com/Abizern/hblog) +- <http://freizl.github.io>, + [source](https://github.com/freizl/freizl.github.com/tree/master/build) ## Hakyll 3.X diff --git a/web/releases.markdown b/web/releases.markdown index 95fad2f..7277ea9 100644 --- a/web/releases.markdown +++ b/web/releases.markdown @@ -4,6 +4,10 @@ title: Releases # Releases +## Hakyll 4.4.3.0 + +- Fix issue when using `metadataRoute` after other custom routes + ## Hakyll 4.4.2.0 - Fix issue where Hakyll would not detect a change if a `.metadata` file was |