diff options
author | Alexander Foremny <aforemny@posteo.de> | 2023-12-04 08:36:02 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2023-12-05 06:07:41 +0100 |
commit | 1b1c3faabae530229eb675a2e70e744c2f45cbbe (patch) | |
tree | acc3e8eede9053fb5e639deeb553aa600c994598 /app/Issue/Meta.hs | |
parent | 3a76b6f0fc0c9c23000dd82870922c885c34ffa6 (diff) |
feat: add experimental render api
Diffstat (limited to 'app/Issue/Meta.hs')
-rw-r--r-- | app/Issue/Meta.hs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/app/Issue/Meta.hs b/app/Issue/Meta.hs index 19ccab3..6e3bbf0 100644 --- a/app/Issue/Meta.hs +++ b/app/Issue/Meta.hs @@ -4,8 +4,13 @@ module Issue.Meta ) where +import Data.List (intersperse) +import Data.Text qualified as T import Issue (Issue (..)) -import Issue.Tag (Tag, tagValue) +import Issue.Render () +import Issue.Tag (Tag, TagKey (..), tagValue) +import Render ((<<<)) +import Render qualified as P data Meta = Meta { referencedBy :: [(Issue, Tag)] @@ -24,3 +29,20 @@ getMeta issues issue = ) issues } + +instance P.Render Meta where + render meta = + if (not $ null meta.referencedBy) + then + P.styled [P.italicized] + . (P.vsep . intersperse P.hardline) + $ map + ( \(otherIssue, tag) -> + ("This commit was referenced by issue " :: T.Text) + <<< P.Linked otherIssue + <<< (" (" :: T.Text) + <<< TagKey tag + <<< (")." :: T.Text) + ) + meta.referencedBy + else P.emptyDoc |