From 061d84a5a523f728cd655d032db6942527272132 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 21 Jan 2024 00:09:45 +0100 Subject: [PATCH 1/9] add jas to friends --- static/badges/friends/jas.webp | 3 +++ templates/index.html | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 static/badges/friends/jas.webp diff --git a/static/badges/friends/jas.webp b/static/badges/friends/jas.webp new file mode 100644 index 0000000..d483d3b --- /dev/null +++ b/static/badges/friends/jas.webp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a87d0ecb14c364bd370c1c593462c0f60190b52e1f2cae3d396e9af4665fbbd +size 1614 diff --git a/templates/index.html b/templates/index.html index f82e6ae..5f164aa 100644 --- a/templates/index.html +++ b/templates/index.html @@ -71,6 +71,14 @@ rel="noreferrer" >102jjwy + + jas {{/data}} From a4af983418949950d4b1d6703107bea5b947fdb8 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 21 Jan 2024 00:10:23 +0100 Subject: [PATCH 2/9] typo --- templates/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 5f164aa..0ca4289 100644 --- a/templates/index.html +++ b/templates/index.html @@ -73,7 +73,7 @@ /> Date: Wed, 24 Jan 2024 11:52:20 +0100 Subject: [PATCH 3/9] variable for data directory path --- src/config.rs | 14 ++++++++++++-- src/main.rs | 2 +- src/routes/blog.rs | 30 ++++++++++++++++++++---------- src/routes/contact.rs | 13 ++++++------- src/routes/portfolio.rs | 4 ++-- 5 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/config.rs b/src/config.rs index fd3a8cf..d1edb9e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -69,13 +69,20 @@ impl FileConfig { } } +// Paths where files are stored +#[derive(Clone, Debug)] +pub struct Locations { + pub static_dir: String, + pub data_dir: String, +} + /// Configuration used internally in the app #[derive(Clone, Debug)] pub struct Config { /// Information given in the config file pub fc: FileConfig, /// Location where the static files are stored - pub static_location: String, + pub locations: Locations, /// Informations about templates pub tmpl: Template, } @@ -110,7 +117,10 @@ pub fn get_config(file_path: &str) -> Config { Config { fc: internal_config.to_owned(), - static_location: format!("{}/{}", files_root, static_dir), + locations: Locations { + static_dir: format!("{}/{}", files_root, static_dir), + data_dir: String::from("data"), + }, tmpl: Template { directory: format!("{}/{}", files_root, templates_dir), app_name: internal_config.app_name.unwrap(), diff --git a/src/main.rs b/src/main.rs index 5058cc3..289fa22 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,7 +60,7 @@ async fn main() -> Result<()> { .service(portfolio::page) .service(setup::page) .service(web3::page) - .service(Files::new("/", config.static_location.to_owned())) + .service(Files::new("/", config.locations.static_dir.to_owned())) .default_service(web::to(not_found::page)) }) .bind(addr)? diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 066e518..c40a36d 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -42,7 +42,7 @@ struct BlogIndexTemplate { #[once(time = 60)] fn build_index(config: Config) -> String { - let mut posts = get_posts("data/blog"); + let mut posts = get_posts(format!("{}/blog", config.locations.data_dir)); // Sort from newest to oldest posts.sort_by_cached_key(|p| (p.date.year, p.date.month, p.date.day)); @@ -81,8 +81,8 @@ struct Post { impl Post { // Fetch the file content - fn fetch_content(&mut self) { - let blog_dir = "data/blog"; + fn fetch_content(&mut self, data_dir: &str) { + let blog_dir = format!("{}/blog", data_dir); let ext = ".md"; if let Some(file) = read_file( @@ -102,8 +102,8 @@ impl Hash for Post { } } -fn get_posts(location: &str) -> Vec { - let entries = match std::fs::read_dir(location) { +fn get_posts(location: String) -> Vec { + let entries = match std::fs::read_dir(&location) { Ok(res) => res .flatten() .filter(|f| match f.path().extension() { @@ -190,7 +190,12 @@ async fn page(path: web::Path<(String,)>, config: web::Data) -> impl Res fn build_post(file: String, config: Config) -> String { let mut post = None; - let (infos, toc) = get_post(&mut post, file, config.fc.name.unwrap_or_default()); + let (infos, toc) = get_post( + &mut post, + file, + config.fc.name.unwrap_or_default(), + config.locations.data_dir, + ); config.tmpl.render( "blog/post.html", @@ -206,8 +211,13 @@ fn build_post(file: String, config: Config) -> String { ) } -fn get_post(post: &mut Option, filename: String, name: String) -> (Infos, String) { - let blog_dir = "data/blog"; +fn get_post( + post: &mut Option, + filename: String, + name: String, + data_dir: String, +) -> (Infos, String) { + let blog_dir = format!("{}/blog", data_dir); let ext = ".md"; *post = read_file( @@ -268,7 +278,7 @@ async fn rss(config: web::Data) -> impl Responder { #[once(time = 10800)] // 3h fn build_rss(config: Config) -> String { - let mut posts = get_posts("data/blog"); + let mut posts = get_posts(format!("{}/blog", config.locations.data_dir)); // Sort from newest to oldest posts.sort_by_cached_key(|p| (p.date.year, p.date.month, p.date.day)); @@ -315,7 +325,7 @@ fn build_rss(config: Config) -> String { .iter_mut() .map(|p| { // Get post data - p.fetch_content(); + p.fetch_content(&config.locations.data_dir); // Build item Item { diff --git a/src/routes/contact.rs b/src/routes/contact.rs index 91b7775..6e6f690 100644 --- a/src/routes/contact.rs +++ b/src/routes/contact.rs @@ -38,13 +38,12 @@ struct ContactLink { } #[once(time = 60)] -fn find_links() -> Vec { - // TOML file location - let contacts_dir = "data/contacts"; +fn find_links(directory: String) -> Vec { + // TOML filename let toml_file = "links.toml"; // Read the TOML file and parse it - let toml_str = read_to_string(format!("{contacts_dir}/{toml_file}")).unwrap_or_default(); + let toml_str = read_to_string(format!("{directory}/{toml_file}")).unwrap_or_default(); let mut redirections = vec![]; match toml::de::from_str::(&toml_str) { @@ -74,9 +73,9 @@ fn find_links() -> Vec { #[routes] #[get("/{service}")] #[get("/{service}/{scope}")] -async fn service_redirection(req: HttpRequest) -> impl Responder { +async fn service_redirection(config: web::Data, req: HttpRequest) -> impl Responder { let info = req.match_info(); - let link = find_links() + let link = find_links(format!("{}/contacts", config.locations.data_dir)) .iter() // Find requested service .filter(|&x| x.service == *info.query("service")) @@ -123,7 +122,7 @@ fn remove_paragraphs(list: &mut [File]) { #[once(time = 60)] fn build_page(config: Config) -> String { - let contacts_dir = "data/contacts"; + let contacts_dir = format!("{}/contacts", config.locations.data_dir); let ext = ".md"; let socials_dir = "socials"; diff --git a/src/routes/portfolio.rs b/src/routes/portfolio.rs index e0fad8d..9b3f1ee 100644 --- a/src/routes/portfolio.rs +++ b/src/routes/portfolio.rs @@ -29,7 +29,7 @@ struct PortfolioTemplate<'a> { #[once(time = 60)] fn build_page(config: Config) -> String { - let projects_dir = "data/projects"; + let projects_dir = format!("{}/projects", config.locations.data_dir); let ext = ".md"; // Get apps @@ -39,7 +39,7 @@ fn build_page(config: Config) -> String { .collect::>(); let appdata = if apps.is_empty() { - (None, Some(projects_dir)) + (None, Some(projects_dir.as_str())) } else { (Some(apps), None) }; From 1467740f60bf9fd3cbb1f977079136765387d65e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:05:41 +0100 Subject: [PATCH 4/9] clippy --- src/routes/contrib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/contrib.rs b/src/routes/contrib.rs index ee1b844..ad51fd9 100644 --- a/src/routes/contrib.rs +++ b/src/routes/contrib.rs @@ -116,20 +116,20 @@ async fn build_page(config: Config) -> String { error: false, projects: Some( data.iter() + .filter(|&p| !p.pulls_merged.is_empty()) .cloned() - .filter(|p| !p.pulls_merged.is_empty()) .collect(), ), waiting: Some( data.iter() + .filter(|&p| !p.pulls_open.is_empty()) .cloned() - .filter(|p| !p.pulls_open.is_empty()) .collect(), ), closed: Some( data.iter() + .filter(|&p| !p.pulls_closed.is_empty()) .cloned() - .filter(|p| !p.pulls_closed.is_empty()) .collect(), ), } From cb67c85040001bc6f955495483a64a7da3dfc718 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:06:59 +0100 Subject: [PATCH 5/9] add generic metada type for md files + comments --- src/misc/markdown.rs | 80 +++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index eb4a6b3..27c16f4 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -6,6 +6,7 @@ use ramhorns::Content; use serde::{Deserialize, Deserializer}; use std::fs; +/// Metadata for blog posts #[derive(Default, Deserialize, Content, Debug)] pub struct FileMetadataBlog { pub title: Option, @@ -16,37 +17,7 @@ pub struct FileMetadataBlog { pub toc: Option, } -#[derive(Default, Deserialize, Content, Debug)] -pub struct FileMetadataContact { - pub title: String, - pub custom: Option, - pub user: Option, - pub link: Option, - pub newtab: Option, - pub description: Option, -} - -#[derive(Default, Deserialize, Content, Debug)] -pub struct FileMetadataPortfolio { - pub title: Option, - pub link: Option, - pub description: Option, - pub language: Option, -} - -pub enum TypeFileMetadata { - Blog, - Contact, - Portfolio, -} - -#[derive(Default, Deserialize, Content, Debug)] -pub struct FileMetadata { - pub blog: Option, - pub contact: Option, - pub portfolio: Option, -} - +/// A tag, related to post blog #[derive(Content, Debug, Clone)] pub struct Tag { pub name: String, @@ -67,6 +38,44 @@ impl<'de> Deserialize<'de> for Tag { } } +/// Metadata for contact entry +#[derive(Default, Deserialize, Content, Debug)] +pub struct FileMetadataContact { + pub title: String, + pub custom: Option, + pub user: Option, + pub link: Option, + pub newtab: Option, + pub description: Option, +} + +/// Metadata for portfolio cards +#[derive(Default, Deserialize, Content, Debug)] +pub struct FileMetadataPortfolio { + pub title: Option, + pub link: Option, + pub description: Option, + pub language: Option, +} + +/// List of available metadata types +pub enum TypeFileMetadata { + Generic, + Blog, + Contact, + Portfolio, +} + +/// Structure who holds all the metadata the file have +/// Usually all fields are None except one +#[derive(Default, Deserialize, Content, Debug)] +pub struct FileMetadata { + pub blog: Option, + pub contact: Option, + pub portfolio: Option, +} + +/// Global metadata #[derive(Content, Debug)] pub struct Metadata { pub info: FileMetadata, @@ -75,6 +84,7 @@ pub struct Metadata { pub syntax_highlight: bool, } +/// File description #[derive(Content, Debug)] pub struct File { pub metadata: Metadata, @@ -214,7 +224,11 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM match root .children() .find_map(|node| match &node.data.borrow().value { + // Extract metadata from frontmatter NodeValue::FrontMatter(text) => Some(match mtype { + TypeFileMetadata::Generic => FileMetadata { + ..FileMetadata::default() + }, TypeFileMetadata::Blog => FileMetadata { blog: Some(deserialize_metadata(text)), ..FileMetadata::default() @@ -240,7 +254,11 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM _ => None, }) { Some(data) => data, + // No metadata None => match mtype { + TypeFileMetadata::Generic => FileMetadata { + ..FileMetadata::default() + }, TypeFileMetadata::Blog => FileMetadata { blog: Some(FileMetadataBlog::default()), ..FileMetadata::default() From fbde0a07c62c967c10bf398718fa06d2fde43a5e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:10:50 +0100 Subject: [PATCH 6/9] documentation --- src/routes/api_v1.rs | 1 + src/routes/contact.rs | 1 + src/template.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/routes/api_v1.rs b/src/routes/api_v1.rs index 5068f02..464e9f3 100644 --- a/src/routes/api_v1.rs +++ b/src/routes/api_v1.rs @@ -1,6 +1,7 @@ use actix_web::{get, HttpResponse, Responder}; use serde::Serialize; +/// Response #[derive(Serialize)] struct Info { unix_epoch: u32, diff --git a/src/routes/contact.rs b/src/routes/contact.rs index 6e6f690..77aba1d 100644 --- a/src/routes/contact.rs +++ b/src/routes/contact.rs @@ -30,6 +30,7 @@ async fn page(config: web::Data) -> impl Responder { Html(build_page(config.get_ref().to_owned())) } +/// Contact node #[derive(Clone, Debug)] struct ContactLink { service: String, diff --git a/src/template.rs b/src/template.rs index e7f873a..fcff2d7 100644 --- a/src/template.rs +++ b/src/template.rs @@ -24,6 +24,7 @@ pub struct Infos { pub page_kw: Option, } +/// Information on what page the user is currently #[derive(Content, Debug, Default)] pub struct NavBar { pub index: bool, From 978cc48a57753cec8246446d49f35871e8000285 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:38:37 +0100 Subject: [PATCH 7/9] index is now a md file, fallback to README, fallback to info about how to setup the index page --- Dockerfile | 1 + README.md | 2 +- src/routes/index.rs | 18 ++++++++++-- static/css/index.css | 4 +-- templates/index.html | 66 ++++---------------------------------------- 5 files changed, 26 insertions(+), 65 deletions(-) diff --git a/Dockerfile b/Dockerfile index c42cd5f..9bfdc3f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ WORKDIR /app COPY --from=builder /usr/local/cargo/bin/ewp /app/ewp COPY --from=builder /usr/src/ewp/LICENSE /app/LICENSE +COPY --from=builder /usr/src/ewp/README.md /app/README.md COPY --from=builder /usr/src/ewp/static /app/static COPY --from=builder /usr/src/ewp/templates /app/templates diff --git a/README.md b/README.md index afacd3e..ae45e61 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ Easy WebPage generator [![status-badge](https://ci.mylloon.fr/api/badges/Anri/mylloon.fr/status.svg)](https://ci.mylloon.fr/Anri/mylloon.fr) - See [issues](https://git.mylloon.fr/Anri/mylloon.fr/issues) -- See [documentation](./Documentation.md) +- See [documentation](https://git.mylloon.fr/Anri/mylloon.fr/src/branch/main/Documentation.md) diff --git a/src/routes/index.rs b/src/routes/index.rs index b8291d8..5ff067d 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -4,7 +4,10 @@ use ramhorns::Content; use crate::{ config::Config, - misc::utils::{make_kw, Html}, + misc::{ + markdown::{read_file, File, TypeFileMetadata}, + utils::{make_kw, Html}, + }, template::{Infos, NavBar}, }; @@ -17,10 +20,20 @@ async fn page(config: web::Data) -> impl Responder { struct IndexTemplate { navbar: NavBar, fullname: String, + content: Option, } #[once(time = 60)] fn build_page(config: Config) -> String { + let mut content = read_file( + &format!("{}/index.md", config.locations.data_dir), + TypeFileMetadata::Generic, + ); + + if content.is_none() { + content = read_file("README.md", TypeFileMetadata::Generic); + } + config.tmpl.render( "index.html", IndexTemplate { @@ -33,11 +46,12 @@ fn build_page(config: Config) -> String { .fullname .to_owned() .unwrap_or("Fullname".to_owned()), + content, }, Infos { page_title: config.fc.fullname, page_desc: Some("Page principale".into()), - page_kw: make_kw(&["index", "étudiant"]), + page_kw: make_kw(&["index", "étudiant", "accueil"]), }, ) } diff --git a/static/css/index.css b/static/css/index.css index ac60ac0..6c654d4 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -64,8 +64,8 @@ h1 { opacity: 1; } -#friends a { - padding-right: 10px; +#friends a:not(h1 > a) { + padding-right: 5px; } #friends h1 { diff --git a/templates/index.html b/templates/index.html index 0ca4289..3eb1916 100644 --- a/templates/index.html +++ b/templates/index.html @@ -22,66 +22,12 @@

-
- -
-

Personnes incroyables

- 21_12 - - Azazouille - - 102jjwy - - jas -
- - {{/data}} + {{#content}} {{&content}} {{/content}} {{^content}} +

+ Welcome to EWP, create a index.md file inside your + data/ directory to get started. +

+ {{/content}} {{/data}} From 17850ae636c637b7c26bc7320c9036d4b108d416 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 12:40:14 +0100 Subject: [PATCH 8/9] alphabetical order --- src/misc/markdown.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index 27c16f4..49e077f 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -60,9 +60,9 @@ pub struct FileMetadataPortfolio { /// List of available metadata types pub enum TypeFileMetadata { - Generic, Blog, Contact, + Generic, Portfolio, } @@ -226,9 +226,6 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM .find_map(|node| match &node.data.borrow().value { // Extract metadata from frontmatter NodeValue::FrontMatter(text) => Some(match mtype { - TypeFileMetadata::Generic => FileMetadata { - ..FileMetadata::default() - }, TypeFileMetadata::Blog => FileMetadata { blog: Some(deserialize_metadata(text)), ..FileMetadata::default() @@ -246,6 +243,9 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM ..FileMetadata::default() } } + TypeFileMetadata::Generic => FileMetadata { + ..FileMetadata::default() + }, TypeFileMetadata::Portfolio => FileMetadata { portfolio: Some(deserialize_metadata(text)), ..FileMetadata::default() @@ -256,9 +256,6 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM Some(data) => data, // No metadata None => match mtype { - TypeFileMetadata::Generic => FileMetadata { - ..FileMetadata::default() - }, TypeFileMetadata::Blog => FileMetadata { blog: Some(FileMetadataBlog::default()), ..FileMetadata::default() @@ -267,6 +264,9 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM contact: Some(FileMetadataContact::default()), ..FileMetadata::default() }, + TypeFileMetadata::Generic => FileMetadata { + ..FileMetadata::default() + }, TypeFileMetadata::Portfolio => FileMetadata { portfolio: Some(FileMetadataPortfolio::default()), ..FileMetadata::default() From c18c0adf3483e74ab1fffd6915f2b98eb0f4886d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 24 Jan 2024 13:09:20 +0100 Subject: [PATCH 9/9] add metadata for index file --- src/misc/markdown.rs | 19 +++++++++++++++++++ src/routes/index.rs | 37 ++++++++++++++++++++++++++----------- templates/index.html | 8 ++++---- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/src/misc/markdown.rs b/src/misc/markdown.rs index 49e077f..7b68b80 100644 --- a/src/misc/markdown.rs +++ b/src/misc/markdown.rs @@ -49,6 +49,15 @@ pub struct FileMetadataContact { pub description: Option, } +/// Metadata for index page +#[derive(Default, Deserialize, Content, Debug)] +pub struct FileMetadataIndex { + pub name: Option, + pub pronouns: Option, + pub avatar: Option, + pub avatar_caption: Option, +} + /// Metadata for portfolio cards #[derive(Default, Deserialize, Content, Debug)] pub struct FileMetadataPortfolio { @@ -63,6 +72,7 @@ pub enum TypeFileMetadata { Blog, Contact, Generic, + Index, Portfolio, } @@ -72,6 +82,7 @@ pub enum TypeFileMetadata { pub struct FileMetadata { pub blog: Option, pub contact: Option, + pub index: Option, pub portfolio: Option, } @@ -246,6 +257,10 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM TypeFileMetadata::Generic => FileMetadata { ..FileMetadata::default() }, + TypeFileMetadata::Index => FileMetadata { + index: Some(deserialize_metadata(text)), + ..FileMetadata::default() + }, TypeFileMetadata::Portfolio => FileMetadata { portfolio: Some(deserialize_metadata(text)), ..FileMetadata::default() @@ -267,6 +282,10 @@ pub fn get_metadata<'a>(root: &'a AstNode<'a>, mtype: TypeFileMetadata) -> FileM TypeFileMetadata::Generic => FileMetadata { ..FileMetadata::default() }, + TypeFileMetadata::Index => FileMetadata { + index: Some(FileMetadataIndex::default()), + ..FileMetadata::default() + }, TypeFileMetadata::Portfolio => FileMetadata { portfolio: Some(FileMetadataPortfolio::default()), ..FileMetadata::default() diff --git a/src/routes/index.rs b/src/routes/index.rs index 5ff067d..bf9db99 100644 --- a/src/routes/index.rs +++ b/src/routes/index.rs @@ -19,19 +19,35 @@ async fn page(config: web::Data) -> impl Responder { #[derive(Content, Debug)] struct IndexTemplate { navbar: NavBar, - fullname: String, + name: String, + pronouns: Option, content: Option, + avatar: String, + avatar_caption: String, } #[once(time = 60)] fn build_page(config: Config) -> String { - let mut content = read_file( + let mut file = read_file( &format!("{}/index.md", config.locations.data_dir), - TypeFileMetadata::Generic, + TypeFileMetadata::Index, ); - if content.is_none() { - content = read_file("README.md", TypeFileMetadata::Generic); + // Default values + let mut name = config.fc.fullname.to_owned().unwrap_or_default(); + let mut pronouns = None; + let mut avatar = "/icons/apple-touch-icon.png".to_owned(); + let mut avatar_caption = "EWP avatar".to_owned(); + + if let Some(f) = &file { + if let Some(m) = &f.metadata.info.index { + name = m.name.to_owned().unwrap_or(name); + avatar = m.avatar.to_owned().unwrap_or(avatar); + pronouns = m.pronouns.to_owned(); + avatar_caption = m.avatar_caption.to_owned().unwrap_or(avatar_caption); + } + } else { + file = read_file("README.md", TypeFileMetadata::Generic); } config.tmpl.render( @@ -41,12 +57,11 @@ fn build_page(config: Config) -> String { index: true, ..NavBar::default() }, - fullname: config - .fc - .fullname - .to_owned() - .unwrap_or("Fullname".to_owned()), - content, + content: file, + name, + pronouns, + avatar, + avatar_caption, }, Infos { page_title: config.fc.fullname, diff --git a/templates/index.html b/templates/index.html index 3eb1916..6c06b7b 100644 --- a/templates/index.html +++ b/templates/index.html @@ -10,13 +10,13 @@ {{#data}}
- {{fullname}} - (il/lui, he/him) + {{name}} + {{#pronouns}}{{pronouns}}{{/pronouns}} Avatar