mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
Write html assets to build folder, and make sure it exists
This commit is contained in:
parent
bf4b2b823f
commit
5b07b1c946
3 changed files with 561 additions and 3 deletions
|
@ -16,6 +16,8 @@ use bumpalo::Bump;
|
|||
use roc_collections::all::MutMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
mod assets;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Template {
|
||||
pub package_name: String,
|
||||
|
@ -56,6 +58,17 @@ pub fn generate(filenames: Vec<PathBuf>, std_lib: StdLib, build_dir: &Path) {
|
|||
modules: files_docs,
|
||||
};
|
||||
|
||||
if !build_dir.exists() {
|
||||
fs::create_dir_all(build_dir).expect("TODO gracefully handle unable to create build dir");
|
||||
}
|
||||
|
||||
fs::write(build_dir.join("search.js"), assets::SEARCH_JS)
|
||||
.expect("TODO gracefully handle failing to make the search javascript");
|
||||
fs::write(build_dir.join("styles.css"), assets::STYLE_CSS)
|
||||
.expect("TODO gracefully handle failing to make the stylesheet");
|
||||
fs::write(build_dir.join("favicon.svg"), assets::FAVICON)
|
||||
.expect("TODO gracefully handle failing to make the favicon");
|
||||
|
||||
// Register handlebars template
|
||||
let mut handlebars = handlebars::Handlebars::new();
|
||||
handlebars
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue