use assetserver::Asset;
use maud::html;
use page::page::{Page, PageMetadata};

use crate::{
	components::{
		fa::FAIcon,
		mangle::{MangledBetaEmail, MangledGoogleEmail},
		md::Markdown,
		misc::FarLink,
	},
	pages::page_wrapper,
	routes::assets::{Image_Cover, Image_Icon},
};

pub fn index() -> Page {
	Page {
		meta: PageMetadata {
			title: "Betalupi: About".into(),
			author: Some("Mark".into()),
			description: Some("Description".into()),
			image: Some(Image_Icon::URL.into()),
			backlinks: Some(false),
		},

		generate_html: Box::new(move |page, _ctx| {
			Box::pin(async {
				let inner = html! {
					h2 id="about" { "About" }

					div {
						img
							src=(Image_Cover::URL)
							style="float:left;margin:10px 10px 10px 10px;display:block;width:25%;"
							{}

						div style="margin:2ex 1ex 2ex 1ex;display:inline-block;overflow:hidden;width:60%;" {
							"Welcome, you've reached Mark's main page. Here you'll find"
							" links to various projects I've worked on."

							ul {
								li { (MangledBetaEmail {}) }
								li { (MangledGoogleEmail {}) }

								li {
									(
										FarLink(
											"https://github.com/rm-dr",
											html!(
												(FAIcon::Github)
												"rm-dr"
											)
										)
									)
								}

								li {
									(
										FarLink(
											"https://git.betalupi.com",
											html!(
												(FAIcon::Git)
												"git.betalupi.com"
											)
										)
									)
								}
							}
						}
						br style="clear:both;" {}
					}

					(Markdown(include_str!("index.md")))
				};

				page_wrapper(&page.meta, inner).await
			})
		}),

		..Default::default()
	}
}
