From f7339b36e450909a6ef4aa487e255197b4c04c9b Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sat, 9 Dec 2023 21:48:40 +0100 Subject: [PATCH] Add draft with color --- Cargo.toml | 2 +- markdowns/posts/test.md | 1 + src/app/models/post.rs | 1 + src/app/pages/posts.rs | 13 +++++++++++++ tailwind.config.js | 6 +++++- 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a2f7b53..bae8e66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "portfolio" -version = "0.1.1" +version = "0.2.1" edition = "2021" [lib] diff --git a/markdowns/posts/test.md b/markdowns/posts/test.md index 93c16c5..fea2c17 100644 --- a/markdowns/posts/test.md +++ b/markdowns/posts/test.md @@ -4,6 +4,7 @@ title: Testing layout date: 2023-11-26 description: Testing the layout of the site. project_link: none +draft: true --- # Heading 1 diff --git a/src/app/models/post.rs b/src/app/models/post.rs index 1a476ec..f9a517a 100644 --- a/src/app/models/post.rs +++ b/src/app/models/post.rs @@ -7,6 +7,7 @@ pub struct PostMetadata { pub date: String, pub description: String, pub project_link: String, + pub draft: bool } #[derive(Clone, Serialize, Deserialize, Debug)] diff --git a/src/app/pages/posts.rs b/src/app/pages/posts.rs index a632c75..4c80768 100644 --- a/src/app/pages/posts.rs +++ b/src/app/pages/posts.rs @@ -73,6 +73,19 @@ pub fn PostElement() -> impl IntoView { view! { <> + { + if post.metadata.draft { + Some(view!{ + <div class="bg-warning text-on_warning dark:bg-dark_warning dark:text-dart_on_warning rounded-md p-5"> + r#" + L'article est en cours d'écriture. La formulation peut ne pas être exacte et les phrases peuvent contenir des fautes. + "# + </div> + }) + } else { + None + } + } <div inner_html={post.content.clone()}></div> </> } diff --git a/tailwind.config.js b/tailwind.config.js index 5b8a588..6f8003b 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -13,7 +13,11 @@ export default { surface: '#fdfbff', dark_surface: '#1a1b1e', on_surface: '#1a1b1e', - dark_on_surface: '#e3e2e6' + dark_on_surface: '#e3e2e6', + on_warning: '#321D0B', + dark_on_warning: '#FFFFFF', + warning: '#fb923c', + dark_warning: '#874512', } }, },