···213213214214```markdown
215215---
216216-title: { { enhance title="Super Title" / } }
216216+title: {{ enhance title="Super Title" /}}
217217---
218218219219Here's an image with a caption:
+2
website/content/docs/installation.md
···4444cd my-website
4545maudit dev
4646```
4747+4848+Note that your first build will take some time if dependencies haven't been downloaded and compiled yet. Subsequent builds will re-use cached dependencies and be much faster.
+26-6
website/content/docs/javascript.md
···44section: "core-concepts"
55---
6677-JavaScript and TypeScript files can be added to pages using the `ctx.assets.add_script()` method.
77+Maudit supports adding JavaScript and TypeScript files to your site.
8899-In [supported templating languages](/docs/templating/), the return value of `ctx.assets.add_script()` can be used directly in the template.
99+To import a script, add it anywhere in your project's directory, and use the `ctx.assets.add_script()` method to add it to a page's assets. Paths are relative to the project's current working directory, not the file where the method is called.
10101111```rs
1212use maudit::route::prelude::*;
1313-use maud::{html};
1313+use maud::{html, Markup};
14141515#[route("/")]
1616pub struct Index;
···1919 fn render(&self, ctx: &mut PageContext) -> impl Into<RenderResult> {
2020 let script = ctx.assets.add_script("script.js");
21212222+ // Access the URL of the script using the `url()` method.
2323+ // This is useful when you want to manually add the script to your template.
2424+ format!(
2525+ r#"<script src="{}" type="module"></script>"#,
2626+ script.url()
2727+ );
2828+2929+ // In supported templating languages, the return value of `ctx.assets.add_script()` can be used directly in the template.
2230 html! {
2331 (script) // Generates <script src="SCRIPT_URL" type="module"></script>
2432 }
···2634}
2735```
28362929-The `include_script()` method can be used to automatically include the script in the page, which can be useful when using layouts or other shared templates.
3737+Alternatively, the `include_script()` method can be used to automatically include the script in the page, without needing to manually add it to the template. This can be useful when a layout or component need to include their own scripts.
30383139```rs
3240fn render(&self, ctx: &mut PageContext) -> impl Into<RenderResult> {
4141+ layout(&ctx, "Look ma, no explicit script tag!")
4242+}
4343+4444+fn layout(ctx: &PageContext, content: &str) -> Markup {
3345 ctx.assets.include_script("script.js");
34463535- layout("Look ma, no explicit script tag!")
4747+ html! {
4848+ head {
4949+ title { "My page" }
5050+ // No need to manually add the script here.
5151+ }
5252+ body {
5353+ (PreEscaped(content))
5454+ }
5555+ }
3656}
3757```
38583939-When using `include_script()`, the script will be included inside the `head` tag with the `type="module"` attribute. [Note that this attribute implicitely means that your script will be deferred](https://v8.dev/features/modules#defer) after the page has loaded. At this time, pages without a `head` tag won't have the script included.
5959+When using `include_script()`, the script will be included inside the `head` tag with the `type="module"` attribute. [Note that this attribute implicitely means that your script will be deferred](https://v8.dev/features/modules#defer) after the page has loaded. Note that, at this time, pages without a `head` tag won't have the script included.
40604161## Transformation & Bundling
4262
+8-9
website/content/docs/performance.md
···11---
22title: "Performance"
33-description: "Learn how to improve the build times and performance of your Maudit site."
33+description: "Learn how to improve the build times of your Maudit site."
44section: "guide"
55---
6677-Maudit can generally [build websites pretty quickly](https://github.com/bruits/maudit/tree/main/benchmarks), but there are a few strategies you can use to improve build times and the performance of your site.
77+Maudit can generally [build websites pretty quickly](https://github.com/bruits/maudit/tree/main/benchmarks), but there are a few strategies you can use to improve build times still.
8899-A Maudit project is a normal Rust project, so [any performance optimizations that apply to Rust projects](https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times) also apply to Maudit projects, but there are a few specific strategies that can help improve the performance of your Maudit site.
99+A Maudit project is a normal Rust project, so [any performance optimizations that apply to Rust projects](https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times) also apply to Maudit projects, but some additional strategies are more specific to Maudit.
10101111## In development
12121313### Cargo settings
14141515-We recommend using the following settings in your `Cargo.toml` to improve build times during development. This will increase the optimization level of your dependencies without making the compile time of your own crate longer.
1515+We recommend using the following settings in your `Cargo.toml` to improve subsequent build times during development. This will increase the optimization level of your dependencies without making the compile time of your own crate longer.
16161717```toml
1818-[profile.dev.package."*"]
1919-opt-level = 3
1818+2019```
21202221This is particularly relevant if you are processing a lot of images, as there is a large difference in performance between debug and release builds of the crates Maudit uses for image processing.
···3332}
3433```
35343636-Running `cargo run` will show which pages of your site are slow to build, allowing you to identify bottlenecks in your build process. Note that it is not generally worth it to disable things such as image processing as Maudit will cache processed images between builds, even in development mode.
3535+Building your project will show which pages of your site are slow to build, allowing you to identify bottlenecks in your build process. Note that it is not generally worth it to disable things such as image processing as Maudit will cache processed images between builds, even in development mode.
37363837### Preventing build directory block
3938···51505251### Release builds
53525454-If not using `maudit build`, ensure you are building your project in release mode using `cargo build --release` or `cargo run --release`. This will significantly improve the performance of your site and is a common pitfall for new users.
5353+If not using `maudit build`, which always build using the release profile, ensure you are building your project in release mode using `cargo build --release` or `cargo run --release`. This will significantly improve the performance of your site and is a common pitfall for new users.
55545655### Caching
57565858-Make sure to cache the `target` directory between builds in your CI/CD pipeline. This will very significantly improve build times, especially if you have a lot of dependencies or processed images. Platforms like Netlify or Vercel will automatically cache the `target` directory for you.
5757+Make sure to cache the `target` directory between builds in your CI/CD pipeline. This will very significantly improve build times, especially if you have a lot of dependencies or processed images. Platforms like [Netlify](https://docs.netlify.com/build/configure-builds/manage-dependencies/#rust) or Vercel will automatically cache the `target` directory for you.
+6-4
website/content/docs/routing.md
···12121313```rs
1414use routes::Index;
1515-use maudit::{coronate, routes, BuildOptions, BuildOutput};
1515+use maudit::{coronate, routes, content_sources, BuildOptions, BuildOutput};
16161717fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
1818 coronate(
1919 routes![Index],
2020- vec![].into(),
2020+ content_sources![],
2121 BuildOptions::default()
2222 )
2323}
···4040}
4141```
42424343-The `Route` trait requires the implementation of a `render` method that returns any types that can be converted into `RenderResult`. This method is called when the page is built and should return the content that will be displayed. In most cases, you'll be using a templating library to create HTML content.
4343+The `Route` trait requires the implementation of a `render` method that returns any types that can be converted into `RenderResult`. This method is called when the page is built and should return the content that will be displayed. In most cases, you'll be [using a templating library](/docs/templating/) to create HTML content.
44444545Maudit implements `Into<RenderResult>` for the following types:
4646···117117118118### Optional parameters
119119120120-Dynamic routes can also have optional parameters by using the `Option<T>` type in the parameters struct. These parameters will be completely removed from the URL and file path when they are `None`. For instance, in a route with the path `/posts/[category]/[slug]`, if the `category` parameter is `None`, the resulting URL will be `/posts/my-blog-post/`.
120120+Dynamic routes can also have optional parameters by using the `Option<T>` type in the parameters struct. These parameters will be completely removed from the URL and file path when they are `None`.
121121+122122+For instance, in a route with the path `/posts/[category]/[slug]`, if the `category` parameter is `None`, the resulting URL will be `/posts/my-blog-post/`.
121123122124This feature is notably useful when creating paginated routes (ex: `/posts/[page]`), where the first page sometimes does not include a page number in the URL, but subsequent pages do (e.g., `/blog` for the first page and `/blog/1` for the second page).
123125
+25-5
website/content/docs/styling.md
···6677Maudit supports styling your site with CSS.
8899-To import a stylesheet, add it anywhere in your project's directory, and use the `ctx.assets.add_style()` method to add it to a page's assets.
1010-1111-In [supported templating languages](/docs/templating/), the return value of `ctx.assets.add_style()` can be used directly in the template.
99+To import a stylesheet, add it anywhere in your project's directory, and use the `ctx.assets.add_style()` method to add it to a page's assets. Paths are relative to the project's current working directory, not the file where the method is called.
12101311```rs
1412use maudit::route::prelude::*;
···2119 fn render(&self, ctx: &mut PageContext) -> impl Into<RenderResult> {
2220 let style = ctx.assets.add_style("style.css");
23212222+ // Access the URL of the stylesheet using the `url()` method.
2323+ // This is useful when you want to manually add the stylesheet to your template.
2424+ format!(
2525+ r#"<link rel="stylesheet" href="{}" />"#,
2626+ style.url()
2727+ );
2828+2929+ // In supported templating languages, the return value of `ctx.assets.add_style()` can be used directly in the template.
2430 html! {
2531 (style) // Generates <link rel="stylesheet" href="STYLE_URL" />
2632 }
···2834}
2935```
30363131-Alternatively, the `include_style()` method can be used to automatically include the stylesheet in the page, without needing to manually add it to the template. Note that, at this time, pages without a `head` tag won't have the stylesheet included.
3737+Alternatively, the `include_style()` method can be used to automatically include the stylesheet in the page, without needing to manually add it to the template. This can be useful when a layout or component need to include its own styles.
32383339```rs
3440fn render(&self, ctx: &mut PageContext) -> impl Into<RenderResult> {
4141+ layout(&ctx, "Look ma, no link tag!")
4242+}
4343+4444+fn layout(ctx: &PageContext, content: &str) -> Markup {
3545 ctx.assets.include_style("style.css");
36463737- layout("Look ma, no link tag!")
4747+ html! {
4848+ head {
4949+ title { "My page" }
5050+ // No need to manually add the stylesheet here.
5151+ }
5252+ body {
5353+ (PreEscaped(content))
5454+ }
5555+ }
3856}
3957```
5858+5959+Note that, at this time, pages without a `head` tag won't have the stylesheet included.
40604161## Tailwind support
4262
+13-2
website/content/docs/templating.md
···10101111## Maud
12121313-Maudit implements `Into<RenderResult>` for the Maud `Markup` type, allowing one to directly return Maud's templates from a page's `render` method.
1313+Maudit implements `Into<RenderResult>` for the Maud `Markup` type, allowing one to directly return Maud's templates from a route's `render` method.
14141515```rs
1616use maud::{html, Markup};
···4848}
4949```
50505151-This is made possible by the `maud` feature, which is enabled by default, but can be disabled using `default-features = false` in your `Cargo.toml` for `maudit`.
5151+To use Maud with Maudit, install Maud into your project by adding it to your `Cargo.toml`, or running `cargo add maud`.
5252+5353+```toml
5454+[dependencies]
5555+maud = "0.27"
5656+```
5757+5858+The `maud` feature is enabled by default. If you have disabled default features, enable it manually:
5959+6060+```toml
6161+maudit = { version = "0.6", features = ["maud"] }
6262+```