Skip to content

Commit 334c3ad

Browse files
authored
Revert "Check the code in the guide (#380)" (#391)
This reverts commit b7f514e.
1 parent b7f514e commit 334c3ad

40 files changed

+860
-1342
lines changed

Cargo.lock

Lines changed: 0 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ dioxus = { version = "0.6.0", features = ["router"] }
1212
dioxus-web = { version = "0.6.0", features = ["hydrate"], optional = true }
1313
dioxus-ssr = { version = "0.6.0", optional = true }
1414
dioxus-desktop = { version = "0.6.0", optional = true }
15-
dioxus-cli-config = { version = "0.6.0", optional = true }
1615
dioxus-liveview = { version = "0.6.0", features = ["axum"], optional = true }
1716

1817
dioxus-material-icons = { git = "https://github.com/jkelleyrtp/dioxus-material-icons", branch = "jk/git-rev" }
@@ -58,7 +57,6 @@ dioxus-sdk = { version = "0.6.0", optional = true }
5857
tower-http = { version = "0.5.0", optional = true, features = ["timeout"] }
5958
tracing = "0.1.40"
6059
rand = { version = "0.8.5", optional = true }
61-
rusqlite = { version = "0.32.1", optional = true }
6260
askama_escape = { version = "0.10.3", optional = true }
6361

6462
[build-dependencies]
@@ -171,7 +169,5 @@ doc_test = [
171169
"http",
172170
"rand",
173171
"server",
174-
"dioxus/fullstack",
175-
"dioxus-cli-config",
176-
"dep:rusqlite"
172+
"dioxus/fullstack"
177173
]

assets/icon.png

-3.21 KB
Binary file not shown.

docs-src/0.4/en/router/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

docs-src/0.6/src/guide/assets.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ The bare-bones template already includes a base `main.css` in the `assets` folde
2929
To include the CSS in our app, we can use the `asset!()` macro. This macro ensures the asset will be included in the final app bundle.
3030

3131
```rust
32-
{{#include src/doc_examples/guide_assets.rs:css_asset}}
32+
static CSS: Asset = asset!("/assets/main.css");
3333
```
3434

3535
We also need to load the asset into our app using the `document::Stylesheet` component. This component is equivalent to the `<link>` HTML element but also ensures the CSS will be pre-loaded during server-side-rendering.
3636

3737
```rust
38-
{{#include src/doc_examples/guide_assets.rs:css_stylesheet}}
38+
fn App() -> Element {
39+
rsx! {
40+
document::Stylesheet { href: CSS }
41+
// rest of the app
42+
}
43+
}
3944
```
4045

4146
Unlike Rust's `include_str!()` macro, the `asset!()` macro does not actually include the *contents* of the asset in our final executable. Instead, it generates a unique path so that the asset can be loaded at runtime. This is ideal for web apps where assets are loaded in parallel through different HTTP requests.
@@ -58,27 +63,39 @@ In Dioxus, you can include images in two ways:
5863
When including assets with a URL, simply fill the `src` attribute of `img {}`. Note that when the app is offline, URL-based images won't download.
5964

6065
```rust
61-
{{#include src/doc_examples/guide_assets.rs:url_image}}
66+
rsx! {
67+
// ...
68+
div {
69+
img { src: "https://images.dog.ceo/breeds/pitbull/dog-3981540_1280.jpg" }
70+
}
71+
// ...
72+
}
6273
```
6374

6475
For static images, you can use the same `asset!()` macro that we used to include the app's CSS.
6576

6677
```rust
67-
{{#include src/doc_examples/guide_assets.rs:asset_image}}
78+
static ICON: Asset = asset!("/assets/icon.png");
79+
80+
rsx! {
81+
img { src: ICON }
82+
}
6883
```
6984

7085
## Optimizations
7186

7287
By default, the `asset!()` macro will lightly optimize CSS, JavaScript, JSON, and images. The name of the asset will also be modified to include a content hash.
7388

7489
```rust
75-
{{#include src/doc_examples/guide_assets.rs:asset_optimization}}
90+
// would output main-j1238nask123.css
91+
asset!("/assets/main.css").to_string()
7692
```
7793

7894
You can optimize assets even further, with an optional `Options` struct. For example, `dx` can automatically convert `.png` images to a more optimized `.avif` format:
7995

8096
```rust
81-
{{#include src/doc_examples/guide_assets.rs:image_asset_expansion}}
97+
// outputs image-j1238jd2.avif
98+
asset!("/assets/image.png", ImageAssetOptions::new().with_avif())
8299
```
83100
For many apps, asset optimization is the most effective way of improving load times. As developers, we frequently overlook the size of images and accidentally make our sites load slower.
84101

0 commit comments

Comments
 (0)