Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from krsch/master
Implemented per-directory metadata support
- Loading branch information
Showing
11 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
module Hakyll.Core.Rules.Default | |||
( internalRules | |||
, addMetadataDependencies | |||
) | |||
where | |||
import Hakyll.Core.Rules | |||
import Hakyll.Core.Compiler | |||
import Hakyll.Core.Compiler.Internal (compilerTellDependencies) | |||
import Hakyll.Core.Metadata (getMatches, metadataFiles) | |||
import Hakyll.Core.Identifier.Pattern(fromList) | |||
|
|||
internalRules :: Rules () | |||
internalRules = do | |||
match "metadata" $ compile $ makeItem () | |||
match "**/metadata" $ compile $ makeItem () | |||
match "**.metadata" $ compile $ makeItem () | |||
|
|||
-------------------------------------------------------------------------------- | |||
addMetadataDependencies :: Compiler () | |||
addMetadataDependencies = | |||
compilerTellDependencies . map IdentifierDependency =<< getMatches . fromList =<< fmap metadataFiles getUnderlying | |||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
-------------------------------------------------------------------------------- | |||
{-# LANGUAGE OverloadedStrings #-} | |||
module Hakyll.Core.Provider.GlobalMetadata.Tests | |||
( tests | |||
) where | |||
|
|||
-------------------------------------------------------------------------------- | |||
import qualified Data.Map as M | |||
import Control.Monad (forM_) | |||
import Test.Framework (Test, testGroup) | |||
import Test.HUnit (Assertion, (@=?)) | |||
|
|||
|
|||
-------------------------------------------------------------------------------- | |||
import Hakyll.Core.Provider (resourceMetadata) | |||
import TestSuite.Util | |||
|
|||
-------------------------------------------------------------------------------- | |||
tests :: Test | |||
tests = testGroup "Hakyll.Core.Provider.GlobalMetadata.Tests" $ | |||
fromAssertions "page" [testPage] | |||
|
|||
testPage :: Assertion | |||
testPage = do | |||
store <- newTestStore | |||
provider <- newTestProvider store | |||
|
|||
metadata <- resourceMetadata provider "posts/2013-10-18-metadata-test.md" | |||
forM_ ["1", "2", "3", "4", "5", "6", "7", "8"] $ \a -> | |||
Just a @=? M.lookup ('a':a) metadata | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
--- posts/2013-10-18-metadata-test.md | |||
a1: 8 | |||
a2: 8 | |||
a3: 8 | |||
a4: 8 | |||
a5: 8 | |||
a6: 8 | |||
a7: 8 | |||
a8: 8 | |||
|
|||
--- posts/* | |||
a1: 7 | |||
a2: 7 | |||
a3: 7 | |||
a4: 7 | |||
a5: 7 | |||
a6: 7 | |||
a7: 7 | |||
|
|||
--- ** | |||
a1: 6 | |||
a2: 6 | |||
a3: 6 | |||
a4: 6 | |||
a5: 6 | |||
a6: 6 | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,4 @@ | |||
--- | |||
a1: 1 | |||
--- | |||
Nothing interesting here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
a1: 2 | |||
a2: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
--- ** | |||
a1: 5 | |||
a2: 5 | |||
a3: 5 | |||
a4: 5 | |||
a5: 5 | |||
|
|||
--- * | |||
a1: 4 | |||
a2: 4 | |||
a3: 4 | |||
a4: 4 | |||
|
|||
--- 2013-10-18-metadata-test.md | |||
a1: 3 | |||
a2: 3 | |||
a3: 3 | |||
|
|||
--- nonexistent | |||
a3: 0 |