diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 61ba685..ed735b4 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -32,16 +32,17 @@ jobs: - name: NPM install run: npm install -D tailwindcss - - name: Install CLI + - name: Install Dioxus CLI run: cargo binstall --no-confirm dioxus-cli --locked --force - - name: Build - run: dx build --release + - name: Install mdbook CLI + run: cargo binstall --no-confirm mdbook --locked --force - - name: Add .nojekyll and fallback 404 - run: | - touch dist/.nojekyll - cp dist/index.html dist/404.html + - name: Make build script executable + run: chmod +x ./build.sh + + - name: Run build script + run: ./build.sh - name: Deploy 🚀 uses: JamesIves/github-pages-deploy-action@v4.2.3 diff --git a/.gitignore b/.gitignore index ef183c8..5c9edd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ target/ **/*.rs.bk dist/ +books/**/book .idea .vscode \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..bd0b25d --- /dev/null +++ b/build.sh @@ -0,0 +1,32 @@ +# REQUIRED BINARIES: +# - dioxus-cli (https://dioxuslabs.com/learn/0.4/CLI/installation) +# - mdbook (https://rust-lang.github.io/mdBook/guide/installation.html) +# - tailwindcss (https://tailwindcss.com/docs/installation) + +set -x -e + +out_dir="./dist" +book_dir="./guides/books" +book_out_dir="${out_dir}/guides/books" + +echo "Cleaning" +cargo clean +dx clean + +echo "Creating necessary directories" +mkdir -p "$book_out_dir" + +echo "Building Dioxus" +dx build --release + +echo "Building books" +for book in "$book_dir"/*; do + if [ -d "$book" ]; then + mdbook build "$book" + mv "$book/book" "$book_out_dir/${book##*/}" + fi +done + +echo "Adding .nojekyll and fallback 404" +touch "$out_dir"/.nojekyll +cp "$out_dir"/index.html "$out_dir"/404.html \ No newline at end of file diff --git a/guides/books/learning-rust-by-making-a-website/book.toml b/guides/books/learning-rust-by-making-a-website/book.toml new file mode 100644 index 0000000..fa12c38 --- /dev/null +++ b/guides/books/learning-rust-by-making-a-website/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["tigerros"] +language = "en" +multilingual = false +src = "src" +title = "Learning Rust by making a website" diff --git a/guides/books/learning-rust-by-making-a-website/src/SUMMARY.md b/guides/books/learning-rust-by-making-a-website/src/SUMMARY.md new file mode 100644 index 0000000..f4550b2 --- /dev/null +++ b/guides/books/learning-rust-by-making-a-website/src/SUMMARY.md @@ -0,0 +1,4 @@ +# Summary + +- [Chapter 1](./chapter_1.md) +- [Chapter 2](chapter_2.md) \ No newline at end of file diff --git a/guides/books/learning-rust-by-making-a-website/src/chapter_1.md b/guides/books/learning-rust-by-making-a-website/src/chapter_1.md new file mode 100644 index 0000000..2dc04a3 --- /dev/null +++ b/guides/books/learning-rust-by-making-a-website/src/chapter_1.md @@ -0,0 +1,3 @@ +# Chapter 1 + +This is just a placeholder! \ No newline at end of file diff --git a/guides/books/learning-rust-by-making-a-website/src/chapter_2.md b/guides/books/learning-rust-by-making-a-website/src/chapter_2.md new file mode 100644 index 0000000..2eb1d48 --- /dev/null +++ b/guides/books/learning-rust-by-making-a-website/src/chapter_2.md @@ -0,0 +1,3 @@ +# Chapter 2 + +This is also just a placeholder! \ No newline at end of file diff --git a/public/tailwind.css b/public/tailwind.css index 26c2435..21914be 100644 --- a/public/tailwind.css +++ b/public/tailwind.css @@ -1 +1 @@ -/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.static{position:static}.mx-auto{margin-left:auto;margin-right:auto}.my-8{margin-top:2rem;margin-bottom:2rem}.flex{display:flex}.table{display:table}.grid{display:grid}.w-2\/3{width:66.666667%}.w-full{width:100%}.grow{flex-grow:1}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.gap-4{gap:1rem}.rounded-md{border-radius:.375rem}.border-2{border-width:2px}.border-blue-2{--tw-border-opacity:1;border-color:rgb(33 33 37/var(--tw-border-opacity))}.bg-blue-1{--tw-bg-opacity:1;background-color:rgb(45 45 55/var(--tw-bg-opacity))}.bg-blue-2{--tw-bg-opacity:1;background-color:rgb(33 33 37/var(--tw-bg-opacity))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.px-4{padding-left:1rem;padding-right:1rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-0{padding-top:0}.text-left{text-align:left}.text-center{text-align:center}.text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-30{transition-delay:30ms}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}body{background-color:#212125}.hover\:border-transparent:hover{border-color:#0000}.hover\:bg-blue-2:hover{--tw-bg-opacity:1;background-color:rgb(33 33 37/var(--tw-bg-opacity))}@media (min-width:768px){.md\:rounded-full{border-radius:9999px}}@media (min-width:1024px){.lg\:w-9\/12{width:75%}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_th\]\:pr-4 th{padding-right:1rem} \ No newline at end of file +/*! tailwindcss v3.3.3 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.visible{visibility:visible}.static{position:static}.sticky{position:sticky}.mx-auto{margin-left:auto;margin-right:auto}.my-8{margin-top:2rem;margin-bottom:2rem}.block{display:block}.flex{display:flex}.table{display:table}.grid{display:grid}.contents{display:contents}.hidden{display:none}.w-2\/3{width:66.666667%}.w-full{width:100%}.grow{flex-grow:1}.resize{resize:both}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.gap-2{gap:.5rem}.gap-4{gap:1rem}.rounded-md{border-radius:.375rem}.border-2{border-width:2px}.border-blue-2{--tw-border-opacity:1;border-color:rgb(33 33 37/var(--tw-border-opacity))}.bg-blue-1{--tw-bg-opacity:1;background-color:rgb(45 45 55/var(--tw-bg-opacity))}.bg-blue-2{--tw-bg-opacity:1;background-color:rgb(33 33 37/var(--tw-bg-opacity))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.px-4{padding-left:1rem;padding-right:1rem}.pb-4{padding-bottom:1rem}.pb-8{padding-bottom:2rem}.pt-0{padding-top:0}.text-left{text-align:left}.text-center{text-align:center}.text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.underline{text-decoration-line:underline}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.delay-30{transition-delay:30ms}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}body{background-color:#212125}.hover\:border-transparent:hover{border-color:#0000}.hover\:bg-blue-2:hover{--tw-bg-opacity:1;background-color:rgb(33 33 37/var(--tw-bg-opacity))}@media (min-width:768px){.md\:rounded-full{border-radius:9999px}}@media (min-width:1024px){.lg\:w-9\/12{width:75%}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_th\]\:pr-4 th{padding-right:1rem} \ No newline at end of file diff --git a/src/components/guide_card.rs b/src/components/guide_card.rs new file mode 100644 index 0000000..a0be5ba --- /dev/null +++ b/src/components/guide_card.rs @@ -0,0 +1,29 @@ + +use dioxus::prelude::*; +use dioxus_router::prelude::*; +use crate::models::Guide; + +#[allow(non_snake_case)] +#[inline_props] +pub fn GuideCard<'a>(cx: Scope, guide: &'a Guide) -> Element { + render! { + div { class: "text-white p-4 bg-blue-1 rounded-md", + table { class: "text-left [&_th]:pr-4", + tr { + th { "👀 Title" } + td { "{guide.title}" } + } + tr { + th { "📜 Description" } + td { "{guide.description}" } + } + tr { + th { "🌐 Website" } + td { + Link { class: "underline", to: "{guide.website}", "{guide.website}" } + } + } + } + } + } +} \ No newline at end of file diff --git a/src/components/guide_grid.rs b/src/components/guide_grid.rs new file mode 100644 index 0000000..682da89 --- /dev/null +++ b/src/components/guide_grid.rs @@ -0,0 +1,15 @@ +use dioxus::prelude::*; +use crate::models::Guide; +use crate::components::GuideCard; + +#[allow(non_snake_case)] +#[inline_props] +pub fn GuideGrid<'a>(cx: Scope, guides: &'a [Guide]) -> Element { + render! { + div { class: "grid grid-cols-1 lg:grid-cols-2 gap-4", + for guide in guides { + GuideCard { key: "{guide.name}", guide: guide } + } + } + } +} \ No newline at end of file diff --git a/src/components/mod.rs b/src/components/mod.rs index f0cffe3..7137454 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,3 +1,3 @@ dry_mods::mods! { - mod pub use layout, navigation, project_card, project_grid; + mod pub use layout, navigation, project_card, project_grid, guide_card, guide_grid; } diff --git a/src/components/navigation.rs b/src/components/navigation.rs index 5d92405..4f61d18 100644 --- a/src/components/navigation.rs +++ b/src/components/navigation.rs @@ -1,28 +1,38 @@ + use dioxus::prelude::*; use dioxus_router::prelude::*; use crate::Route; -const NAVBAR_LINK_ACTIVE_STYLE: &str = "bg-blue-2"; -const NAVBAR_LINK_STYLE: &str = "p-1 px-4 justify-center grow flex text-white hover:border-transparent hover:bg-blue-2 border-2 border-blue-2 rounded-md md:rounded-full transition ease-in-out delay-30"; +#[derive(Props)] +struct NavigationLinkProps<'a> { + pub label: &'a str, + /// Same as the corresponding [`LinkProps`](https://docs.rs/dioxus-router/latest/dioxus_router/components/struct.LinkProps.html) property. + #[props(into)] + pub to: IntoRoutable, +} + +#[allow(non_snake_case)] +fn NavigationLink<'a>(cx: Scope<'a, NavigationLinkProps<'static>>) -> Element<'a> { + let NavigationLinkProps { to, label } = cx.props; + + render! { + Link { + active_class: "bg-blue-2", + class: "p-1 px-4 justify-center grow flex text-white hover:border-transparent hover:bg-blue-2 border-2 border-blue-2 rounded-md md:rounded-full transition ease-in-out delay-30", + to: to.clone(), + "{label}" + } + } +} #[allow(non_snake_case)] -#[inline_props] pub fn Navigation(cx: Scope) -> Element { render! { nav { class: "mx-auto p-2 flex flex-wrap bg-blue-1 rounded-md md:rounded-full gap-2", - Link { - active_class: NAVBAR_LINK_ACTIVE_STYLE, - class: NAVBAR_LINK_STYLE, - to: Route::Home {}, - "Home" - } - Link { class: NAVBAR_LINK_STYLE, to: "https://github.com/dioxus-community", "GitHub" } - Link { - active_class: NAVBAR_LINK_ACTIVE_STYLE, - class: NAVBAR_LINK_STYLE, - to: Route::OurProjects {}, - "Our projects" - } + NavigationLink { to: Route::Home {}, label: "Home" } + NavigationLink { to: "https://github.com/dioxus-community", label: "GitHub" } + NavigationLink { to: Route::OurProjects {}, label: "Our projects" } + NavigationLink { to: Route::Guides {}, label: "Guides" } } } } \ No newline at end of file diff --git a/src/components/project_card.rs b/src/components/project_card.rs index dfef2ed..531bf55 100644 --- a/src/components/project_card.rs +++ b/src/components/project_card.rs @@ -116,9 +116,7 @@ async fn fetch_star_count(repository_url: String) -> Result { return Err(format!("couldn't get repository owner from the repository URL segments. Segments: {segments:?}")); }; let Some(repo) = segments.next() else { - return Err(format!( - "couldn't get repository name from the repository URL segments. Segments: {segments:?}" - )); + return Err(format!("couldn't get repository name from the repository URL segments. Segments: {segments:?}")); }; let get_url = format!("{GITHUB_API_BASE_URL}/repos/{owner}/{repo}"); @@ -127,9 +125,7 @@ async fn fetch_star_count(repository_url: String) -> Result { return Err(format!("reqwest: Couldn't send request to {get_url:?}")); }; let Ok(response) = response.text().await else { - return Err(format!( - "reqwest: Couldn't parse response as text. Response URL: {get_url:?}" - )); + return Err(format!("reqwest: Couldn't parse response as text. Response URL: {get_url:?}")); }; let Some(stargazers_prop_index) = response.find(STARGAZERS_PROPERTY_PATTERN) else { @@ -156,9 +152,7 @@ async fn fetch_star_count(repository_url: String) -> Result { if c.is_numeric() { let Some(c_digit) = c.to_digit(10) else { - return Err(format!( - "couldn't convert char {c:?} to a digit using a radix of 10" - )); + return Err(format!("couldn't convert char {c:?} to a digit using a radix of 10")); }; star_count = (star_count * 10) + (c_digit as usize); diff --git a/src/guides.rs b/src/guides.rs new file mode 100644 index 0000000..4e0fe0a --- /dev/null +++ b/src/guides.rs @@ -0,0 +1,29 @@ +use crate::models::{Guide, ProjectCategory}; + +macro_rules! book_guide { + ( + title: $title:expr, + name: $name:expr, + description: $description:expr, + category: $category:expr, + ) => { + crate::models::Guide { + title: $title, + name: $name, + description: $description, + website: concat!( + "guides/books/", + $name, + "/index.html" + ), + category: $category, + } + }; +} + +pub const GUIDES: [Guide; 1] = [book_guide! { + title: "Learning Rust by making a website", + name: "learning-rust-by-making-a-website", + description: "Description", + category: ProjectCategory::App, +}]; diff --git a/src/main.rs b/src/main.rs index 3761ad1..c8cdf90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,12 +3,14 @@ use dioxus_router::prelude::*; use log::LevelFilter; mod components; +mod guides; mod models; mod our_projects; mod routes; use components::*; -use our_projects::*; +use guides::GUIDES; +use our_projects::OUR_PROJECTS; use routes::*; const GITHUB_API_BASE_URL: &str = "https://api.github.com"; @@ -38,6 +40,8 @@ pub enum Route { Home {}, #[route("/our-projects")] OurProjects {}, + #[route("/guides")] + Guides { }, #[route("/:..segments")] NotFound { segments: Vec }, } diff --git a/src/models/guide.rs b/src/models/guide.rs new file mode 100644 index 0000000..318213a --- /dev/null +++ b/src/models/guide.rs @@ -0,0 +1,10 @@ +use crate::models::ProjectCategory; + +#[derive(PartialEq, Clone, Debug)] +pub struct Guide { + pub title: &'static str, + pub name: &'static str, + pub website: &'static str, + pub description: &'static str, + pub category: ProjectCategory, +} \ No newline at end of file diff --git a/src/models/mod.rs b/src/models/mod.rs index dd36776..4cdf0c4 100644 --- a/src/models/mod.rs +++ b/src/models/mod.rs @@ -1,3 +1,3 @@ dry_mods::mods! { - mod pub use project, project_category, project_status; + mod pub use project, project_category, project_status, guide; } diff --git a/src/models/project.rs b/src/models/project.rs index c0215a3..71b5d1a 100644 --- a/src/models/project.rs +++ b/src/models/project.rs @@ -1,6 +1,5 @@ use std::borrow::Cow; use crate::models::ProjectCategory; - use super::ProjectStatus; #[derive(PartialEq, Clone, Debug)] diff --git a/src/models/project_category.rs b/src/models/project_category.rs index 76f64d0..352300b 100644 --- a/src/models/project_category.rs +++ b/src/models/project_category.rs @@ -11,6 +11,7 @@ pub enum ProjectCategory { Logging, Renderer, Deployment, + Security, } impl ProjectCategory { @@ -24,6 +25,7 @@ impl ProjectCategory { Self::Logging => "📡 Logging", Self::Renderer => "🎥 Renderer", Self::Deployment => "⚙️ Deployment", + Self::Security => "🔒 Security", } } } diff --git a/src/our_projects.rs b/src/our_projects.rs index 51d3655..43e6d22 100644 --- a/src/our_projects.rs +++ b/src/our_projects.rs @@ -47,7 +47,7 @@ macro_rules! our_project { }; } -pub const OUR_PROJECTS: &[Project<'static>] = &[ +pub const OUR_PROJECTS: [Project<'static>; 4] = [ our_project! { name: "Dioxus Redux", description: "State management", diff --git a/src/routes/guides.rs b/src/routes/guides.rs new file mode 100644 index 0000000..c2b8bff --- /dev/null +++ b/src/routes/guides.rs @@ -0,0 +1,17 @@ +use dioxus::prelude::*; + +use crate::GUIDES; +use crate::components::{GuideGrid}; + +#[allow(non_snake_case)] +#[inline_props] +pub fn Guides(cx: Scope) -> Element { + render! { + div { class: "text-white", + p { class: "w-2/3 text-center mx-auto pb-4", + "A list of some guides that will help you in your Dioxus journey!" + } + div { class: "mx-auto lg:w-9/12", GuideGrid { guides: &GUIDES } } + } + } +} \ No newline at end of file diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 5a4fb20..4a0e7f7 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,3 +1,3 @@ dry_mods::mods! { - mod pub use home, our_projects, not_found; + mod pub use home, our_projects, not_found, guides; }