From 8fa598ae7eb8c014657cea787376109b7f4c5d18 Mon Sep 17 00:00:00 2001 From: mo8it Date: Sat, 17 May 2025 20:20:19 +0200 Subject: [PATCH] Add details shortcode --- website/content/setup/index.md | 43 +++++++++++------------ website/content/usage/index.md | 11 +++--- website/input.css | 2 +- website/templates/shortcodes/details.html | 9 +++++ 4 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 website/templates/shortcodes/details.html diff --git a/website/content/setup/index.md b/website/content/setup/index.md index 14984a6b..db4ed40f 100644 --- a/website/content/setup/index.md +++ b/website/content/setup/index.md @@ -6,17 +6,16 @@ title = "Setup" ## Installing Rust -Before installing Rustlings, you need to have the **latest version of Rust** installed. -Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. +Before installing Rustlings, you must have the **latest version of Rust** installed. +Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions. This will also install _Cargo_, Rust's package/project manager. -> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). +> 🐧 If you are on Linux, make sure you have `gcc` installed (_for a linker_). > -> Deb: `sudo apt install gcc` -> -> Dnf: `sudo dnf install gcc` +> Debian: `sudo apt install gcc`\ +> Fedora: `sudo dnf install gcc` -> šŸŽ If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. +> šŸŽ If you are on MacOS, make sure you have _Xcode and its developer tools_ installed: `xcode-select --install` ## Installing Rustlings @@ -26,14 +25,13 @@ The following command will download and compile Rustlings: cargo install rustlings ``` -
-If the installation fails… (click to expand) +{% details(summary="If the installation fails…") %} -> - Make sure you have the latest Rust version by running `rustup update` -> - Try adding the `--locked` flag: `cargo install rustlings --locked` -> - Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) +- Make sure you have the latest Rust version by running `rustup update` +- Try adding the `--locked` flag: `cargo install rustlings --locked` +- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) -
+{% end %} ## Initialization @@ -43,18 +41,17 @@ After installing Rustlings, run the following command to initialize the `rustlin rustlings init ``` -
-If the command rustlings can't be found… (click to expand) +{% details(summary="If the command rustlings can't be found…") %} -> You are probably using Linux and installed Rust using your package manager. -> -> Cargo installs binaries to the directory `~/.cargo/bin`. -> Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. -> -> - Either add `~/.cargo/bin` manually to `PATH` -> - Or uninstall Rust from the package manager and [install it using the official way with `rustup`](https://www.rust-lang.org/tools/install) +You are probably using Linux and installed Rust using your package manager. -
+Cargo installs binaries to the directory `~/.cargo/bin`. +Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. + +- Either add `~/.cargo/bin` manually to `PATH` +- Or uninstall Rust from the package manager and [install it using the official way with `rustup`](https://www.rust-lang.org/tools/install) + +{% end %} Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: diff --git a/website/content/usage/index.md b/website/content/usage/index.md index 7c8b0ddb..eecb7d2d 100644 --- a/website/content/usage/index.md +++ b/website/content/usage/index.md @@ -23,14 +23,13 @@ After the [initialization](@/setup/index.md#initialization), Rustlings can be la This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. -
-If detecting file changes in the exercises/ directory fails… (click to expand) +{% details(summary="If detecting file changes in the exercises/ directory fails…") %} -> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. -> -> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). +You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. -
+Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). + +{% end %} ## Exercise List diff --git a/website/input.css b/website/input.css index 3dd55013..b2536753 100644 --- a/website/input.css +++ b/website/input.css @@ -41,7 +41,7 @@ @apply md:w-3/4 lg:w-3/5; } blockquote { - @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm italic; + @apply px-3 pt-2 pb-0.5 my-4 border-s-4 border-white/80 bg-white/7 rounded-sm; } pre { diff --git a/website/templates/shortcodes/details.html b/website/templates/shortcodes/details.html new file mode 100644 index 00000000..c32d7c87 --- /dev/null +++ b/website/templates/shortcodes/details.html @@ -0,0 +1,9 @@ +
+ + {{ summary | safe }} (click to expand) + + +
+ {{ body | markdown | safe }} +
+