diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 025c236..063c57c 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -19,6 +19,7 @@ data Info = Info { date :: !Day, title :: !(Maybe Text), + artist :: !(Maybe Artist), -- nothing = me, obv tags :: ![Text], nsfwTags :: ![Text], description :: !(Maybe Text), @@ -28,6 +29,13 @@ data Info = } deriving (Eq, Show) +data Artist = + Artist { + name :: !Text, + url :: !(Maybe Text) + } + deriving (Eq, Show) + data Image = Image { label :: !Text, @@ -49,6 +57,7 @@ instance FromYAML Info where parseYAML = YAML.withMap "info" \m -> Info <$> m .: "date" <*> m .:? "title" + <*> m .:? "artist" <*> m .:? "tags" .!= [] <*> m .:? "nsfwTags" .!= [] <*> m .:? "description" @@ -56,6 +65,12 @@ instance FromYAML Info where <*> m .: "thumb" <*> m .:? "links" .!= [] +instance FromYAML Artist where + parseYAML y = justName y <|> withUrl y where + justName = YAML.withStr "name" \name -> pure $ Artist {name, url = Nothing} + withUrl = YAML.withMap "full info" \m -> + Artist <$> m .: "name" <*> m .:? "url" + instance FromYAML Image where parseYAML = labelledOptNsfw Image "path" "path"