import * as metadata from "../metadata";
import { Page } from "../metadata";
import * as util from "../util";
import layout from "../layout";

export default async function archive(posts: Page[]) {
	const page = await metadata.get("site/archive.html.ejs");
	page.text = util.render(page.text, {
		posts,
	}, "site/archive.html.ejs");
	page.text = await layout(page.text, page.metadata, page.metadata.layout!);
	util.write("archive/index.html", page.text);
}
