shikensu haskell
v0.4.1
シーケンス
Sequenz
Führen Sie eine Folge von Funktionen für speicherinterne Darstellungen von Dateien aus.
Erstellen Sie ganz einfach statische Websites , ohne sich an eine bestimmte Struktur halten zu müssen.
import Shikensu
import Shikensu.Contrib ( clone , copyPropsToMetadata , permalink , renameExt , renderContent )
import Shikensu.Contrib.IO ( read , write )
import Data.ByteString ( ByteString )
import Flow
import Prelude hiding ( read )
import qualified Data.Text.Encoding as Text ( decodeUtf8 , encodeUtf8 )
main :: IO Dictionary
main =
-- This IO operation will read the files matching the glob pattern `src/**/*.md`,
-- transform them (see the `flow` function) and then write them to the `build` directory.
dictionary_io
dictionary_io :: IO Dictionary
dictionary_io =
Shikensu. listRelative [ " src/**/*.md " ] " ./ "
>>= read
>>= flow
>>= write " ./build "
flow :: Dictionary -> IO Dictionary
flow =
renameExt " .md " " .html "
.> permalink " index "
.> clone " index.html " " 200.html "
.> copyPropsToMetadata
.> renderContent markdownRenderer
.> return
markdownRenderer :: Definition -> Maybe ByteString
markdownRenderer def =
content def
|> fmap Text. decodeUtf8
|> fmap Markdown. render
|> fmap Text. encodeUtf8
Hier werden alle Markdown-Dateien im Verzeichnis ./src
aufgelistet
und führt dann Folgendes in genau dieser Reihenfolge aus:
.html
.%matched_path/%file_basename/index.%file_extension
.index.html
.content
jeder Definition zu (in diesem Fall rendern wir Markdown)../build
.Denn so kann ich ganz einfach einen Workflow für die Erstellung einer statischen Website definieren, und zwar: