shikensu haskell
v0.4.1
시켄스
순서
파일의 메모리 내 표현에 대해 일련의 함수를 실행합니다.
특정 구조를 따르지 않고도 정적 웹사이트를 쉽게 구축할 수 있습니다 .
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
./src
디렉터리에 있는 모든 마크다운 파일이 나열됩니다.
그런 다음 정확한 순서로 다음을 수행합니다.
.html
로 변경합니다.%matched_path/%file_basename/index.%file_extension
으로 변경합니다.index.html
경로가 있는 파일의 메모리 내 복사본을 만듭니다.content
속성을 매핑합니다(이 경우 마크다운을 렌더링합니다)../build
디렉터리에 씁니다.이를 통해 정적 웹 사이트 구축을 위한 워크플로를 쉽게 정의할 수 있으며, 더 구체적으로는 다음과 같습니다.