Skip to content
This repository was archived by the owner on Jul 19, 2020. It is now read-only.

Commit 6446d6f

Browse files
committed
add page describing how to add static assets
1 parent 37c24db commit 6446d6f

File tree

3 files changed

+43
-7
lines changed

3 files changed

+43
-7
lines changed

src/SUMMARY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
## More
3535

36-
* [CSS](more/css.md)
36+
* [Static Content](more/static.md)
3737
* [Roadmap](more/roadmap.md)
3838
* [Testing](more/testing.md)
3939
* [External Libs](more/external-libs.md)

src/more/css.md

-6
This file was deleted.

src/more/static.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Static Content
2+
3+
Static content in Yew is served from the `static` directory in your crate. For example, if you have a folder structure like:
4+
5+
```
6+
myapp
7+
├── src/
8+
│ └── lib.rs
9+
├── static/
10+
│ └── script.js
11+
├── Cargo.lock
12+
└── Cargo.toml
13+
```
14+
15+
## HTML
16+
17+
Yew compiles to a single-page application, with one JavaScript bundle that can be imported into an HTML page. Yew generates boilerplate HTML page out of the box, but you can create a custom one in `static/index.html` if you wish to override this.
18+
19+
Your application will be built at `/crate.js`. For example, for your custom HTML page that imports some CSS, you might have:
20+
21+
```html
22+
<!DOCTYPE html>
23+
<html lang="en">
24+
<head>
25+
<meta charset="UTF-8">
26+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
27+
<title>My Awesome App!</title>
28+
<!-- references /static/mystyles.css -->
29+
<link rel="stylesheet" href="/mystyles.css">
30+
</head>
31+
<body>
32+
<script src="/myapp.js"></script>
33+
</body>
34+
</html>
35+
```
36+
37+
## CSS
38+
39+
A proposal for proper CSS support can be found here: [https://github.com/yewstack/yew/issues/533](https://github.com/yewstack/yew/issues/533).
40+
41+
For now, you can reference stylesheets be creating a custom `index.html` within the `static` directory.
42+

0 commit comments

Comments
 (0)