NOTE: Federation is disabled on this instance!
You can test federation between the following instances:forge.angeley.es
code.angeley.es
By | fr33domlover |
At | 2018-02-19 |
Title | Access git repo in template context |
Description |
Edit file site.cabal 33188 → 33188
3 | 3 | build-type: Simple |
|
4 | 4 | cabal-version: >= 1.10 |
|
5 | 5 | ||
6 | 6 | executable site |
|
7 | 7 | main-is: site.hs |
|
- | 8 | build-depends: base == 4.* |
|
+ | 8 | build-depends: base == 4.* |
|
9 | 9 | , filepath |
|
- | 10 | , hakyll == 4.9.* |
|
+ | 10 | , filestore |
|
+ | 11 | , hakyll == 4.9.* |
|
+ | 12 | , hakyll-filestore |
|
11 | 13 | ghc-options: -threaded |
|
12 | 14 | default-language: Haskell2010 |
|
… | … | … | … |
Edit file site.hs 33188 → 33188
12 | 12 | -} |
|
13 | 13 | ||
14 | 14 | {-# LANGUAGE OverloadedStrings #-} |
|
15 | 15 | ||
16 | 16 | import Data.Monoid ((<>), mappend) |
|
+ | 17 | import Data.FileStore.Types (FileStore) |
|
17 | 18 | import Hakyll |
|
+ | 19 | import Hakyll.FileStore.Context (fsModificationTimeField) |
|
+ | 20 | import Hakyll.FileStore.Git.Context (gitStore) |
|
18 | 21 | import System.FilePath ((</>), dropExtension) |
|
19 | 22 | ||
+ | 23 | fileStore :: FileStore |
|
+ | 24 | fileStore = gitStore |
|
+ | 25 | ||
20 | 26 | pageRoute :: Routes |
|
21 | 27 | pageRoute = customRoute $ (</> "index.html") . dropExtension . toFilePath |
|
22 | 28 | ||
+ | 29 | dateFormat :: String |
|
+ | 30 | dateFormat = "%B %e, %Y" |
|
+ | 31 | ||
23 | 32 | postCtx :: Context String |
|
24 | 33 | postCtx = |
|
- | 25 | dateField "date" "%B %e, %Y" `mappend` |
|
- | 26 | defaultContext |
|
+ | 34 | dateField "date" dateFormat |
|
+ | 35 | <> fsModificationTimeField fileStore "mtime" dateFormat |
|
+ | 36 | <> defaultContext |
|
27 | 37 | ||
28 | 38 | main :: IO () |
|
29 | 39 | main = hakyll $ do |
|
30 | 40 | match "images/*" $ do |
|
31 | 41 | route idRoute |
|
… | … | … | … |
Edit file stack.yaml 33188 → 33188
34 | 34 | # |
|
35 | 35 | # A package marked 'extra-dep: true' will only be built if demanded by a |
|
36 | 36 | # non-dependency (i.e. a user package), and its test suites and benchmarks |
|
37 | 37 | # will not be run. This is useful for tweaking upstream packages. |
|
38 | 38 | packages: |
|
- | 39 | - . |
|
+ | 39 | - . |
|
40 | 40 | ||
41 | 41 | # Dependency packages to be pulled from upstream that are not in the resolver |
|
42 | 42 | # (e.g., acme-missiles-0.3) |
|
- | 43 | extra-deps: [] |
|
+ | 43 | extra-deps: |
|
+ | 44 | - filestore-0.6.3.1 |
|
+ | 45 | - hakyll-filestore-0.1.5 |
|
44 | 46 | ||
45 | 47 | # Override default flag values for local packages and extra-deps |
|
46 | 48 | flags: {} |
|
47 | 49 | ||
48 | 50 | # Extra package databases containing global packages |
|
… | … | … | … |