pub fn write_index(
    dat: &mut Vec<Entry>,
    reg: &Handlebars,
    cfg: &Config,
) -> Result<(), Error> {
    let dst_dir = cfg.build.get_target_dir();
    let path = Path::new(&dst_dir).join("index.html");
    let mut file = fs::File::create(path)?;

    // reverse sorting
    dat.sort_by(|a, b| b.cmp(a));

    let mut meta = &mut json!({
        "website": cfg.website.to_json(),
        "headlines": json!(&dat),
    });
    meta = merge_authors(meta, cfg);

    let result = reg
        .render("layout", meta)
        .map_err(|e| Error::new(ErrorKind::InvalidInput, e))?;
    file.write_all(result.as_bytes())?;
    Ok(())
}
/// writes the index file into dst directory.
writes the index file into dst directory.
writes the index file into dst directory .
pub fn write_index(
    dat: &mut Vec<Entry>,
    reg: &Handlebars,
    cfg: &Config,
) -> Result<(), Error> {
    let dst_dir = cfg.build.get_target_dir();
    let path = Path::new(&dst_dir).join("index.html");
    let mut file = fs::File::create(path)?;
    // reverse sorting
    dat.sort_by(|a, b| b.cmp(a));
    let mut meta = &mut json!({
        "website": cfg.website.to_json(),
        "headlines": json!(&dat),
    });
    meta = merge_authors(meta, cfg);
    let result = reg
        .render("layout", meta)
        .map_err(|e| Error::new(ErrorKind::InvalidInput, e))?;
    file.write_all(result.as_bytes())?;
    Ok(())
}
pub fn write_index ( dat : & mut Vec < Entry > , reg : & Handlebars , cfg : & Config , ) -> Result < ( ) , Error > { let dst_dir = cfg . build . get_target_dir ( ) ; let path = Path :: new ( & dst_dir ) . join ( " " ) ; let mut file = fs :: File :: create ( path ) ? ; // reverse sorting dat . sort_by ( | a , b | b . cmp ( a ) ) ; let mut meta = & mut json ! ( { " " cfg website to_json ( ) " " json ( dat ) } ) ; meta = merge_authors ( meta , cfg ) ; let result = reg . render ( " " , meta ) . map_err ( | e | Error :: new ( ErrorKind :: InvalidInput , e ) ) ? ; file . write_all ( result . as_bytes ( ) ) ? ; Ok ( ( ) ) }
writes the index file into dst directory.
writes the index file into dst directory .
dat
&mut Vec<Entry>
reg
&Handlebars
cfg
&Config
dat
&mut Vec<Entry>
reg
&Handlebars
cfg
&Config