mirror of
https://github.com/Noratrieb/website.git
synced 2026-01-15 01:15:02 +01:00
static stuff
This commit is contained in:
parent
56da12a5bc
commit
148a5352a3
8 changed files with 237 additions and 2 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
mod blog;
|
||||
mod slides;
|
||||
mod statics;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
|
|
@ -9,7 +10,12 @@ use color_eyre::{eyre::Context, Result};
|
|||
|
||||
use crate::Config;
|
||||
|
||||
pub fn assemble_website(config: &Config, submodules: &Path, dist: &Path) -> Result<()> {
|
||||
pub fn assemble_website(
|
||||
config: &Config,
|
||||
statics: &Path,
|
||||
submodules: &Path,
|
||||
dist: &Path,
|
||||
) -> Result<()> {
|
||||
blog::build(&submodules.join("blog"), &dist.join("blog")).wrap_err("building blog")?;
|
||||
slides::build(
|
||||
&config.slides,
|
||||
|
|
@ -18,6 +24,8 @@ pub fn assemble_website(config: &Config, submodules: &Path, dist: &Path) -> Resu
|
|||
)
|
||||
.wrap_err("building slides")?;
|
||||
|
||||
statics::build(&config.slides, statics, dist).wrap_err("building root files")?;
|
||||
|
||||
add_cname(dist)?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
29
src/build/statics.rs
Normal file
29
src/build/statics.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//! Root index.html and some other static stuff
|
||||
|
||||
use std::{fs, path::Path};
|
||||
|
||||
use askama::Template;
|
||||
use color_eyre::{eyre::WrapErr, Result};
|
||||
|
||||
use crate::{utils, SlidesConfig};
|
||||
|
||||
#[derive(askama::Template)]
|
||||
#[template(path = "slides.html")]
|
||||
struct Slides {
|
||||
talks: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn build(config: &SlidesConfig, statics: &Path, dist: &Path) -> Result<()> {
|
||||
utils::cp_content(&statics.join("root"), dist).wrap_err("copying root files")?;
|
||||
|
||||
let slide_html = Slides {
|
||||
talks: config.talks.clone(),
|
||||
}
|
||||
.render()
|
||||
.wrap_err("rendering slide index")?;
|
||||
|
||||
fs::write(dist.join("slides").join("index.html"), slide_html)
|
||||
.wrap_err("writing slides index.html")?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue