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OFOHQBAEVJEF52PJHAJOPHQECY6QC
DLJPWVRPZ5E4TC7IXF4DBPN3KQZCC4F5GBT222Q4W4FAJSAIHBFQC
H6SY4TCOYCGKYC77SWG4EUEW225SPJT4JGG4YEM2Z4JI2WHWVPYAC
YW6L24ISNOHNZWFUPTUGCKGAGGOQO2H5IYZARK6ST35VGLVXUYDAC
-- Important note :
-- Hakyll does not manage org metadata. We follow @nasyxx hack mentioned here
-- https://github.com/jaspervdj/hakyll/issues/700
-- with a slight modification in cleanRouteFromTemp
-- The idea is to generate in _temp the file with YAML metada on top on org metadat
-- Then a second pass is needed to generate actual HTML
--------------------------------------------------------------------------------
match "posts/*" $ do
route $ setExtension "html"
-- Hack : generate temporary files for correcting metadata
match ("posts/*.org" .||. "genetique/*.org") $ do
route tempRoute
compile $ getResourceString >>= orgCompiler
match ("_temp/posts/*.org" .||. "_temp/genetique/*.org") $ do
route $ cleanRouteFromTemp
match "genetique/*.org" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" defaultContext
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
-- Don't forget to set the path to temporary files
--------------------------------------------------------------------------------
cleanRouteFromTemp :: Routes
cleanRouteFromTemp = customRoute createIndexRoute
where
createIndexRoute ident =
(joinPath . tail . splitDirectories . takeDirectory) p
</> takeFileName p -<.> ".html"
where p = toFilePath ident
-- | From org get metadatas.
orgCompiler :: Item String -> Compiler (Item String)
orgCompiler = pure . fmap (\s -> (metadatasToStr . orgMetadatas) s ++ s)
orgMetadatas :: String -> [String]
orgMetadatas = map (format . lower . clean) . takeWhile (/= "") . lines
where
clean = concat . splitOn "#+"
lower s = (map toLower . takeWhile (/= ':')) s ++ dropWhile (/= ':') s
format xs
| -- drop weekday str. 2018-05-03 Thu -> 2018-05-03
"date" `isPrefixOf` xs
= take 16 . concat . splitOn ">" . concat . splitOn "<" $ xs
| otherwise
= xs
metadatasToStr :: [String] -> String
metadatasToStr = ("----------\n" ++) . (++ "----------\n") . unlines
----