shikensu haskell
v0.4.1
シーケンス
Secuencia
Ejecute una secuencia de funciones en representaciones de archivos en memoria.
Cree sitios web estáticos con facilidad , sin ajustarse a una estructura específica.
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
Esto enumera todos los archivos de rebajas en el directorio ./src
y luego hace lo siguiente en este orden exacto:
.html
.%matched_path/%file_basename/index.%file_extension
.index.html
.content
de cada definición (en este caso, estamos representando rebajas)../build
.Porque esto me permite definir fácilmente un flujo de trabajo para crear un sitio web estático y, más específicamente: