@@ -55,6 +55,7 @@ import Nirum.Version (versionText)
55
55
56
56
data Docs = Docs
57
57
{ docsTitle :: T. Text
58
+ , docsOpenGraph :: [OpenGraph ]
58
59
, docsStyle :: T. Text
59
60
, docsHeader :: T. Text
60
61
, docsFooter :: T. Text
@@ -68,6 +69,11 @@ data CurrentPage
68
69
| DocumentPage FilePath
69
70
deriving (Eq , Show )
70
71
72
+ data OpenGraph = OpenGraph
73
+ { ogTag :: T. Text
74
+ , ogContent :: T. Text
75
+ } deriving (Eq , Ord , Show )
76
+
71
77
makeFilePath :: ModulePath -> FilePath
72
78
makeFilePath modulePath' = foldl (</>) " " $
73
79
map toNormalizedString (toList modulePath') ++ [" index.html" ]
@@ -103,6 +109,8 @@ $doctype 5
103
109
<meta name="generator" content="Nirum #{versionText}">
104
110
$forall Author { name = name' } <- authors md
105
111
<meta name="author" content="#{name'}">
112
+ $forall OpenGraph { ogTag, ogContent } <- docsOpenGraph $ target pkg
113
+ <meta property="#{ogTag}" content="#{ogContent}">
106
114
<link rel="stylesheet" href="#{root}style.css">
107
115
<body>
108
116
#{preEscapedToMarkup $ docsHeader $ target pkg}
@@ -616,15 +624,32 @@ instance Target Docs where
616
624
targetName _ = " docs"
617
625
parseTarget table = do
618
626
title <- stringField " title" table
627
+ opengraphs <- optional $ opengraphsField " opengraphs" table
619
628
style <- optional $ stringField " style" table
620
629
header <- optional $ stringField " header" table
621
630
footer <- optional $ stringField " footer" table
622
631
return Docs
623
632
{ docsTitle = title
633
+ , docsOpenGraph = fromMaybe [] opengraphs
624
634
, docsStyle = fromMaybe " " style
625
635
, docsHeader = fromMaybe " " header
626
636
, docsFooter = fromMaybe " " footer
627
637
}
628
638
compilePackage = compilePackage'
629
639
showCompileError _ = id
630
640
toByteString _ = id
641
+
642
+ opengraphsField :: MetadataField -> Table -> Either MetadataError [OpenGraph ]
643
+ opengraphsField field' table = do
644
+ array <- tableArrayField field' table
645
+ opengraphs' <- mapM parseOpenGraph array
646
+ return $ toList opengraphs'
647
+ where
648
+ parseOpenGraph :: Table -> Either MetadataError OpenGraph
649
+ parseOpenGraph t = do
650
+ tag' <- stringField " tag" t
651
+ content' <- stringField " content" t
652
+ return OpenGraph
653
+ { ogTag = tag'
654
+ , ogContent = content'
655
+ }
0 commit comments