Skip to content

Commit af6d1b6

Browse files
committed
fix: separate parts as complexity increase
1 parent 9726ae7 commit af6d1b6

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

site.hs

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import Data.Ord (comparing)
99

1010
main :: IO ()
1111
main = hakyll $ do
12+
13+
--------------------------------------------------------------------------------------------------------
14+
-- STATICS ---------------------------------------------------------------------------------------------
15+
--------------------------------------------------------------------------------------------------------
16+
1217
match "assets/css/main.css" $ do
1318
route idRoute
1419
compile compressCssCompiler
@@ -17,6 +22,10 @@ main = hakyll $ do
1722
route idRoute
1823
compile copyFileCompiler
1924

25+
--------------------------------------------------------------------------------------------------------
26+
-- HOME ------------------------------------------------------------------------------------------------
27+
--------------------------------------------------------------------------------------------------------
28+
2029
match "index.html" $ do
2130
route idRoute
2231
compile $ do
@@ -26,30 +35,36 @@ main = hakyll $ do
2635
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
2736
>>= relativizeUrls
2837

29-
match "affiliates/*.markdown" $ compile pandocCompiler
30-
3138
match "donations/sponsors/*.markdown" $ compile pandocCompiler
32-
33-
match "affiliates/index.html" $ do
39+
match "**/index.html" $ do
3440
route idRoute
3541
compile $ do
36-
affils <- affiliatesCtx . sortOn itemIdentifier <$> loadAll "affiliates/*.markdown"
37-
sponsors <- sponsorsCtx affils . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
38-
42+
sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
3943
getResourceBody
4044
>>= applyAsTemplate sponsors
4145
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
4246
>>= relativizeUrls
4347

44-
match "**/index.html" $ do
48+
--------------------------------------------------------------------------------------------------------
49+
-- AFFILIATES ------------------------------------------------------------------------------------------
50+
--------------------------------------------------------------------------------------------------------
51+
52+
match "affiliates/*.markdown" $ compile pandocCompiler
53+
match "affiliates/index.html" $ do
4554
route idRoute
4655
compile $ do
47-
sponsors <- sponsorsCtx defaultContext . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
56+
affils <- affiliatesCtx . sortOn itemIdentifier <$> loadAll "affiliates/*.markdown"
57+
sponsors <- sponsorsCtx affils . sortOn itemIdentifier <$> loadAll "donations/sponsors/*.markdown"
58+
4859
getResourceBody
4960
>>= applyAsTemplate sponsors
5061
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
5162
>>= relativizeUrls
5263

64+
--------------------------------------------------------------------------------------------------------
65+
-- PROJECTS --------------------------------------------------------------------------------------------
66+
--------------------------------------------------------------------------------------------------------
67+
5368
match "projects/*.markdown" $ compile pandocCompiler
5469

5570
create ["projects/index.html"] $ do
@@ -66,6 +81,10 @@ main = hakyll $ do
6681
match "news/**.markdown" $ compile pandocCompiler
6782
categories <- buildCategories "news/**.markdown" (fromCapture "news/categories/**.html")
6883

84+
--------------------------------------------------------------------------------------------------------
85+
-- NEWS ------------------------------------------------------------------------------------------------
86+
--------------------------------------------------------------------------------------------------------
87+
6988
tagsRules categories $ \category catId -> compile $ do
7089
news <- recentFirst =<< loadAll catId
7190
let ctx =
@@ -91,9 +110,20 @@ main = hakyll $ do
91110
>>= loadAndApplyTemplate "templates/boilerplate.html" sponsors
92111
>>= relativizeUrls
93112

113+
--------------------------------------------------------------------------------------------------------
114+
-- TEMPLATES -------------------------------------------------------------------------------------------
115+
--------------------------------------------------------------------------------------------------------
116+
94117
match "templates/*" $ compile templateBodyCompiler
95118
match "templates/**" $ compile templateBodyCompiler
96119

120+
--------------------------------------------------------------------------------------------------------
121+
--------------------------------------------------------------------------------------------------------
122+
123+
--------------------------------------------------------------------------------------------------------
124+
-- CONTEXT ---------------------------------------------------------------------------------------------
125+
--------------------------------------------------------------------------------------------------------
126+
97127
-- | Partition affiliates into affiliates and pending
98128
affiliatesCtx :: [Item String] -> Context String
99129
affiliatesCtx tuts =
@@ -152,6 +182,10 @@ newsWithCategoriesCtx categories =
152182
newsCtx :: Context String
153183
newsCtx = newsWithCategoriesCtx categories
154184

185+
--------------------------------------------------------------------------------------------------------
186+
-- UTILS -----------------------------------------------------------------------------------------------
187+
--------------------------------------------------------------------------------------------------------
188+
155189
-- | filter list of item string based on the given value to match on the given metadata field
156190
ofMetadataField :: String -> String -> [Item String] -> Compiler [Item String]
157191
ofMetadataField field value = filterM (\item -> do

0 commit comments

Comments
 (0)