summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Hakyll/Web/Template/Context.hs4
-rw-r--r--tests/Hakyll/Web/Template/Context/Tests.hs4
-rw-r--r--tests/data/posts/2018-09-26.md1
3 files changed, 7 insertions, 2 deletions
diff --git a/lib/Hakyll/Web/Template/Context.hs b/lib/Hakyll/Web/Template/Context.hs
index dae241c..0d71386 100644
--- a/lib/Hakyll/Web/Template/Context.hs
+++ b/lib/Hakyll/Web/Template/Context.hs
@@ -50,7 +50,7 @@ import Hakyll.Core.Metadata
import Hakyll.Core.Provider
import Hakyll.Core.Util.String (needlePrefix, splitAll)
import Hakyll.Web.Html
-import System.FilePath (splitDirectories, takeBaseName)
+import System.FilePath (splitDirectories, takeBaseName, dropExtension)
--------------------------------------------------------------------------------
@@ -300,7 +300,7 @@ getItemUTC :: MonadMetadata m
getItemUTC locale id' = do
metadata <- getMetadata id'
let tryField k fmt = lookupString k metadata >>= parseTime' fmt
- paths = splitDirectories $ toFilePath id'
+ paths = splitDirectories $ (dropExtension . toFilePath) id'
maybe empty' return $ msum $
[tryField "published" fmt | fmt <- formats] ++
diff --git a/tests/Hakyll/Web/Template/Context/Tests.hs b/tests/Hakyll/Web/Template/Context/Tests.hs
index f263391..d4a9035 100644
--- a/tests/Hakyll/Web/Template/Context/Tests.hs
+++ b/tests/Hakyll/Web/Template/Context/Tests.hs
@@ -41,6 +41,10 @@ testDateField = do
dateField "date" "%B %e, %Y"
date2 @=? "August 26, 2010"
+ date3 <- testContextDone store provider
+ "posts/2018-09-26.md" "date" $
+ dateField "date" "%B %e, %Y"
+ date3 @=? "September 26, 2018"
cleanTestEnv
diff --git a/tests/data/posts/2018-09-26.md b/tests/data/posts/2018-09-26.md
new file mode 100644
index 0000000..038229a
--- /dev/null
+++ b/tests/data/posts/2018-09-26.md
@@ -0,0 +1 @@
+Something happened today.