mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Website redesign
This commit is contained in:
@ -15,6 +15,7 @@ object Cmd {
|
||||
}
|
||||
|
||||
def run(cmd: Seq[String], wd: File, logger: Logger): Unit = {
|
||||
logger.info(s"Running ${cmd.mkString(" ")}")
|
||||
val res = Cmd.exec(cmd, Some(wd))
|
||||
logger.info(res.out)
|
||||
logger.error(res.err)
|
||||
|
@ -2,6 +2,7 @@ package docspell.build
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
import sbt.nio.file.FileTreeView
|
||||
import scala.sys.process._
|
||||
|
||||
object ZolaPlugin extends AutoPlugin {
|
||||
@ -74,10 +75,12 @@ object ZolaPlugin extends AutoPlugin {
|
||||
case Some(url) =>
|
||||
Seq("--base-url", url)
|
||||
case None =>
|
||||
runYarnInstall("yarn", inDir.getParentFile, logger)
|
||||
runElmCompile("elm", inDir.getParentFile, inDir, logger)
|
||||
Seq.empty
|
||||
}
|
||||
runYarnInstall("yarn", inDir.getParentFile, logger)
|
||||
runElmCompile("elm", inDir.getParentFile, inDir, logger)
|
||||
runTailwind("npx", inDir.getParentFile, inDir, logger)
|
||||
|
||||
Cmd.run(
|
||||
Seq(zolaCmd, "build", "-o", outDir.absolutePath.toString) ++ baseUrl,
|
||||
inDir,
|
||||
@ -106,4 +109,39 @@ object ZolaPlugin extends AutoPlugin {
|
||||
logger
|
||||
)
|
||||
|
||||
def runTailwind(npx: String, inDir: File, zolaRoot: File, logger: Logger): Unit = {
|
||||
val fontTarget = zolaRoot / "static" / "files"
|
||||
val iconTarget = zolaRoot / "static" / "webfonts"
|
||||
IO.createDirectories(Seq(fontTarget, iconTarget))
|
||||
|
||||
val fontIn = Glob(inDir / "node_modules" / "@fontsource") / * / "files" / *
|
||||
val fontInFiles = FileTreeView.default.list(fontIn).map(_._1.toFile())
|
||||
logger.info(s"Copy ${fontInFiles.size} webfonts from node_modules to ${fontTarget}…")
|
||||
IO.copy(fontInFiles.pair(Path.flat(fontTarget)))
|
||||
|
||||
val iconIn =
|
||||
Glob(inDir / "node_modules" / "@fortawesome" / "fontawesome-free" / "webfonts") / *
|
||||
val iconInFiles = FileTreeView.default.list(iconIn).map(_._1.toFile())
|
||||
logger.info(s"Copy ${iconInFiles.size} icons from node_modules to ${iconTarget}…")
|
||||
IO.copy(iconInFiles.pair(Path.flat(iconTarget)))
|
||||
|
||||
logger.info("Running tailwind…")
|
||||
Cmd.run(
|
||||
Seq(
|
||||
npx,
|
||||
"tailwindcss",
|
||||
"-i",
|
||||
(inDir / "styles" / "input.css").toString,
|
||||
"-o",
|
||||
(zolaRoot / "static" / "styles.css").toString,
|
||||
"--config",
|
||||
(inDir / "tailwind.config.js").toString,
|
||||
"--postcss",
|
||||
(inDir / "postcss.config.js").toString,
|
||||
"--minify"
|
||||
),
|
||||
inDir,
|
||||
logger
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user