···11+---
22+title: "Assets"
33+description: "Welcome to the Maudit documentation!"
44+section: "core-concepts"
55+---
66+77+Maudit supports importing assets like images, stylesheets, and scripts into your project and pages.
88+99+### Images
1010+1111+To import an image, add it anywhere in your project's directory, and use the `ctx.assets.add_image()` method to add it to a page's assets.
1212+1313+Like other assets, images can be used directly in Maud templates.
1414+1515+```rust
1616+use maudit::page::prelude::*;
1717+use maud::html;
1818+1919+#[route("/blog")]
2020+pub struct Blog;
2121+2222+impl Page for Blog {
2323+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
2424+ let image = ctx.assets.add_image("logo.png");
2525+2626+ html! {
2727+ (image) // Generates <img src="IMAGE_URL" loading="lazy" decoding="async" />
2828+ }
2929+ }
3030+}
3131+```
3232+3333+Alternatively, if not using Maud, the `url()` method on the image can be used to generate the HTML.
3434+3535+```rust
3636+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
3737+ let image = ctx.assets.add_image("logo.png");
3838+3939+ RenderResult::Html(format!("<img src=\"{}\" loading=\"lazy\" decoding=\"async\" />", image.url().unwrap()))
4040+ }
4141+```
4242+4343+At this time, images are not automatically optimized or resized, but this will be added in the future.
4444+4545+### Stylesheets
4646+4747+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.
4848+4949+When using Maud, the return value of `ctx.assets.add_style()` can be used directly in the template.
5050+5151+```rust
5252+use maudit::page::prelude::*;
5353+use maud::html;
5454+5555+#[route("/blog")]
5656+pub struct Blog;
5757+5858+impl Page for Blog {
5959+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
6060+ let style = ctx.assets.add_style("style.css", false);
6161+6262+ html! {
6363+ (style) // Generates <link rel="stylesheet" href="STYLE_URL" />
6464+ }
6565+ }
6666+}
6767+```
6868+6969+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.
7070+7171+```rust
7272+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
7373+ ctx.assets.include_style("style.css", false);
7474+7575+ html! {
7676+ div {
7777+ "Look ma, no explicit link tag!"
7878+ }
7979+ }
8080+ }
8181+```
8282+8383+#### Tailwind support
8484+8585+Maudit includes built-in support for [Tailwind CSS](https://tailwindcss.com/). To use it, pass `true` as the second argument to `add_style()` or `include_style()`.
8686+8787+```rust
8888+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
8989+ ctx.assets.add_style("style.css", true);
9090+9191+ html! {
9292+ div.bg-red-500 {
9393+ "Wow, such red!"
9494+ }
9595+ }
9696+ }
9797+```
9898+9999+To configure Tailwind, add a [`tailwind.config.js` file](https://tailwindcss.com/docs/configuration) to your project's root directory. This file will be automatically detected and used by Maudit.
100100+101101+### Scripts
102102+103103+JavaScript and TypeScript files can be added to pages using the `ctx.assets.add_script()` method.
104104+105105+```rust
106106+use maudit::page::prelude::*;
107107+108108+#[route("/blog")]
109109+pub struct Blog;
110110+111111+impl Page for Blog {
112112+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
113113+ let script = ctx.assets.add_script("script.js");
114114+115115+ html! {
116116+ (script) // Generates <script src="SCRIPT_URL" type="module"></script>
117117+ }
118118+ }
119119+}
120120+```
121121+122122+As with stylesheets, 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.
123123+124124+```rust
125125+ fn render(&self, ctx: &mut RouteContext) -> RenderResult {
126126+ ctx.assets.include_script("script.js");
127127+128128+ html! {
129129+ div {
130130+ "Look ma, no explicit script tag!"
131131+ }
132132+ }
133133+ }
134134+```
135135+136136+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 after the page has loaded. At this time, pages without a `head` tag won't have the script included.
137137+138138+### Transformation & Bundling
139139+140140+Maudit uses [Rolldown](https://rolldown.rs) to process and bundle scripts and styles. Rolldown will automatically chunk, minify, transpile, etc. your scripts and stylesheets, optimizing them for production. Features like tree shaking, minification, TypeScript support and more are all included out of the box.
141141+142142+At this time, Maudit does not support customizing the transformation process, but this will be added in the future.
+35-1
website/content/docs/entrypoint.md
···11---
22title: "Entrypoint"
33description: "Welcome to the Maudit documentation!"
44+section: "core-concepts"
45---
5666-Something
77+At the core of a Maudit project is the `coronate` function. This function starts the build process and generates the output files. It is the entrypoint to your project and is where you define the pages, content and options that make up your website.
88+99+In a `main.rs` file, import the `coronate` function and call it to build your project. Here is an example of a simple Maudit project:
1010+1111+```rust
1212+use maudit::{coronate, routes, BuildOptions, BuildOutput};
1313+use pages::Index;
1414+1515+fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
1616+ coronate(routes![Index], vec![].into(), BuildOptions::default())
1717+}
1818+```
1919+2020+### Registering Routes
2121+2222+All kinds of routes must be passed to the `coronate` function in order for them to be built.
2323+2424+The first argument to the `coronate` function is a `Vec` of all the routes that should be built. For the sake of ergonomics, the `routes!` macro can be used to create this list.
2525+2626+```rust
2727+use pages::Index;
2828+2929+coronate(
3030+ routes![Index],
3131+ vec![].into(),
3232+ BuildOptions::default()
3333+)
3434+```
3535+3636+See the [Routing](/docs/routing) documentation for more information on how to define routes.
3737+3838+### Content
3939+4040+### Options