module Rules.Src.Style ( rules ) where import Hakyll import System.FilePath (joinPath) import Config (contentsRoot) rules :: Rules () rules :: Rules () rules = do Pattern -> Rules () -> Rules () match Pattern css (Rules () -> Rules ()) -> Rules () -> Rules () forall a b. (a -> b) -> a -> b $ do Routes -> Rules () route (Routes -> Rules ()) -> Routes -> Rules () forall a b. (a -> b) -> a -> b $ String -> (String -> String) -> Routes gsubRoute String "contents/css/" ((String -> String) -> Routes) -> (String -> String) -> Routes forall a b. (a -> b) -> a -> b $ String -> String -> String forall a b. a -> b -> a const String "style/" Compiler (Item String) -> Rules () forall a. (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules () compile Compiler (Item String) compressCssCompiler Dependency scssDepend <- Pattern -> Rules Dependency forall (m :: * -> *). MonadMetadata m => Pattern -> m Dependency makePatternDependency Pattern scssDep Pattern -> Rules () -> Rules () match Pattern scssDep (Rules () -> Rules ()) -> Rules () -> Rules () forall a b. (a -> b) -> a -> b $ Compiler (Item String) -> Rules () forall a. (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules () compile Compiler (Item String) getResourceBody [Dependency] -> Rules () -> Rules () forall a. [Dependency] -> Rules a -> Rules a rulesExtraDependencies [Dependency scssDepend] (Rules () -> Rules ()) -> Rules () -> Rules () forall a b. (a -> b) -> a -> b $ Pattern -> Rules () -> Rules () match Pattern scss (Rules () -> Rules ()) -> Rules () -> Rules () forall a b. (a -> b) -> a -> b $ do Routes -> Rules () route (Routes -> Rules ()) -> Routes -> Rules () forall a b. (a -> b) -> a -> b $ String -> (String -> String) -> Routes gsubRoute String "contents/scss/" (String -> String -> String forall a b. a -> b -> a const String "style/") Routes -> Routes -> Routes `composeRoutes` String -> Routes setExtension String "css" Compiler (Item String) -> Rules () forall a. (Binary a, Typeable a, Writable a) => Compiler (Item a) -> Rules () compile ((String -> String) -> Item String -> Item String forall a b. (a -> b) -> Item a -> Item b forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap String -> String compressCss (Item String -> Item String) -> Compiler (Item String) -> Compiler (Item String) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Compiler (Item String) sassCompiler) where css :: Pattern css = String -> Pattern fromGlob (String -> Pattern) -> String -> Pattern forall a b. (a -> b) -> a -> b $ [String] -> String joinPath [String contentsRoot, String "css", String "**"] scssDep :: Pattern scssDep = String -> Pattern fromGlob (String -> Pattern) -> String -> Pattern forall a b. (a -> b) -> a -> b $ [String] -> String joinPath [String contentsRoot, String "scss", String "*", String "**.scss"] scss :: Pattern scss = String -> Pattern fromGlob (String -> Pattern) -> String -> Pattern forall a b. (a -> b) -> a -> b $ [String] -> String joinPath [String contentsRoot, String "scss", String "*.scss"] sassCompiler :: Compiler (Item String) sassCompiler = Compiler (Item String) getResourceString Compiler (Item String) -> (Item String -> Compiler (Item String)) -> Compiler (Item String) forall a b. Compiler a -> (a -> Compiler b) -> Compiler b forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= (String -> Compiler String) -> Item String -> Compiler (Item String) forall a b. (a -> Compiler b) -> Item a -> Compiler (Item b) withItemBody (String -> [String] -> String -> Compiler String unixFilter String "npx" [String "sass", String "-I", String "node_modules", String "-I", String "contents/scss", String "--stdin"])