diff options
author | pacien | 2019-12-29 13:53:28 +0100 |
---|---|---|
committer | pacien | 2019-12-29 13:53:28 +0100 |
commit | 430ab983587c525004d2aa0dc8e7707312c7ab60 (patch) | |
tree | 78ba8c88a195d06028b546b78fcad6d4382a4c0a | |
parent | 119d837edce4d4c109539b6722fab162ab29c0b0 (diff) | |
download | ldgallery-430ab983587c525004d2aa0dc8e7707312c7ab60.tar.gz |
compiler: handle empty sidecar files
GitHub: closes #1
-rw-r--r-- | compiler/src/Input.hs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs index 64c1933..c90db5c 100644 --- a/compiler/src/Input.hs +++ b/compiler/src/Input.hs | |||
@@ -69,13 +69,21 @@ data Sidecar = Sidecar | |||
69 | , tags :: Maybe [String] | 69 | , tags :: Maybe [String] |
70 | } deriving (Generic, FromJSON, Show) | 70 | } deriving (Generic, FromJSON, Show) |
71 | 71 | ||
72 | emptySidecar :: Sidecar | ||
73 | emptySidecar = Sidecar | ||
74 | { title = Nothing | ||
75 | , date = Nothing | ||
76 | , description = Nothing | ||
77 | , tags = Nothing } | ||
78 | |||
72 | 79 | ||
73 | readInputTree :: AnchoredFSNode -> IO InputTree | 80 | readInputTree :: AnchoredFSNode -> IO InputTree |
74 | readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root | 81 | readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root |
75 | where | 82 | where |
76 | mkInputNode :: FSNode -> IO (Maybe InputTree) | 83 | mkInputNode :: FSNode -> IO (Maybe InputTree) |
77 | mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename = | 84 | mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename = |
78 | decodeYamlFile (localPath $ anchor /> path) | 85 | (decodeYamlFile (localPath $ anchor /> path) :: IO (Maybe Sidecar)) |
86 | >>= return . maybe emptySidecar id | ||
79 | >>= return . InputFile ((dropExtension filename):pathto) | 87 | >>= return . InputFile ((dropExtension filename):pathto) |
80 | >>= return . Just | 88 | >>= return . Just |
81 | mkInputNode File{} = return Nothing | 89 | mkInputNode File{} = return Nothing |