diff options
-rw-r--r-- | src/Hakyll/Core/Metadata.hs | 3 | ||||
-rw-r--r-- | src/Hakyll/Core/Provider/Metadata.hs | 12 | ||||
-rw-r--r-- | src/Hakyll/Core/Rules/Default.hs | 1 | ||||
-rw-r--r-- | tests/data/posts/metadata | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/Hakyll/Core/Metadata.hs b/src/Hakyll/Core/Metadata.hs index a330636..a123c18 100644 --- a/src/Hakyll/Core/Metadata.hs +++ b/src/Hakyll/Core/Metadata.hs @@ -67,7 +67,8 @@ makePatternDependency pattern = do -------------------------------------------------------------------------------- -- | Returns a list of all directory-wise metadata files, subdir first, global last metadataFiles :: Identifier -> [Identifier] -metadataFiles = go . takeDirectory . toFilePath where +metadataFiles identifier = local : go (takeDirectory $ toFilePath identifier) where go "." = [fromFilePath "metadata"] go dir = fromFilePath (dir </> "metadata") : go (takeDirectory dir) + local = fromFilePath $ toFilePath identifier ++ ".metadata" diff --git a/src/Hakyll/Core/Provider/Metadata.hs b/src/Hakyll/Core/Provider/Metadata.hs index a54b84a..889291f 100644 --- a/src/Hakyll/Core/Provider/Metadata.hs +++ b/src/Hakyll/Core/Provider/Metadata.hs @@ -46,7 +46,7 @@ loadMetadata p identifier = do gmd <- loadGlobalMetadata p identifier - return (M.unions [md, emd, gmd], body) + return (M.unions [md, gmd], body) where normal = setVersion Nothing identifier fp = resourceFilePath p identifier @@ -154,11 +154,13 @@ loadGlobalMetadata p fp = liftM M.fromList $ loadgm fp where concatMap snd . filter (flip matches fp . fromGlob . normalise . combine dir . fst) namedMetadata :: Parser [(String, [(String, String)])] -namedMetadata = P.many namedMetadataBlock +namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True -namedMetadataBlock :: Parser (String, [(String, String)]) -namedMetadataBlock = do - name <- P.many1 (P.char '-') *> P.many inlineSpace *> P.manyTill P.anyChar newline +namedMetadataBlock :: Bool -> Parser (String, [(String, String)]) +namedMetadataBlock isNamed = do + name <- if isNamed + then P.many1 (P.char '-') *> P.many inlineSpace *> P.manyTill P.anyChar newline + else pure "**" metadata' <- metadata P.skipMany P.space return (name, metadata') diff --git a/src/Hakyll/Core/Rules/Default.hs b/src/Hakyll/Core/Rules/Default.hs index ccca1bd..fee78c5 100644 --- a/src/Hakyll/Core/Rules/Default.hs +++ b/src/Hakyll/Core/Rules/Default.hs @@ -14,6 +14,7 @@ internalRules :: Rules () internalRules = do match "metadata" $ compile $ makeItem () match "**/metadata" $ compile $ makeItem () + match "**.metadata" $ compile $ makeItem () -------------------------------------------------------------------------------- addMetadataDependencies :: Compiler () diff --git a/tests/data/posts/metadata b/tests/data/posts/metadata index e5cd153..4a1be71 100644 --- a/tests/data/posts/metadata +++ b/tests/data/posts/metadata @@ -16,3 +16,5 @@ a1: 3 a2: 3 a3: 3 +--- nonexistent +a3: 0 |