mirror of
https://github.com/yewstack/yew.git
synced 2026-02-01 17:26:28 +00:00
* Add `--open` to `boids` * Added running instructions to `contexts` * Amended `counter` instructions - Added `--open` flag - Removed unnecessary instructions on how to run with `release` profile * Amended `counter_functional` instructions - Added `--open` flag - Removed unnecessary instructions on how to run with `release` profile * Amended `dyn_create_destroy_apps` instructions - Added `--open` flag - Removed unnecessary instructions on how to run with `release` profile * Added running instructions to `file_upload` * Added running instructions to `function_memory_game`` * Amended `function_router` instructions - Amended `release` profile instructions - Added `--open` flag * Added running instructions to `function_todomvc` * Added running instructions to `futures` * Added running instructions to `game_of_life` * Added running instructions to `immutable` * Added running instructions to `inner_html` * Added running instructions to `js_callback` * Amended `keyed_list` instructions - Added `--open` flag - Amended `release` profile notice * Added running instructions to `mount_point` * Added running instructions to `nested_list` * Added running instructions to `node_refs` * Amended `password_strength` instructions - Added `--open` flag - Amended `release` profile notice * Added running instructions to `portals` * Amended `router` instructions - Added `--open` flag - Amended `release` profile notice * Amended `simple_ssr` instructions - Simplified wording - Removed unnecessary notes - Changed commands so that they should be executed from the `examples/simple_ssr` directory like every other example * Amended `ssr_router` instructions - Removed unnecessary notes - Changed commands so that they should be executed from the `examples/ssr_router` directory like every other example * Added running instructions to `suspense` * Added running instructions to `timer` * Added running instructions to `todo_mvc` * Added running instructions to `two_apps` * Added running instructions to `web_worker_fib` * Added running instructions to `webgl` * Amended various examples - Simplified running instructions - Moved running instructions to the bottom of each `README.md` * Amended `examples/README.md` instructions - Added `release` profile notice - Added `--open` flag - Removed `--release` flag * Apply grammar suggestions from code review Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com> * Update examples/function_router/README.md Grammar Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com> * Add Grammar Suggestions from Review * Apply Spelling Suggestion Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com> --------- Co-authored-by: Kaede Hoshikawa <futursolo@users.noreply.github.com>
51 lines
2.0 KiB
Markdown
51 lines
2.0 KiB
Markdown
# Function Router Example
|
|
|
|
This is identical to the router example, but written in function
|
|
components.
|
|
|
|
[](https://examples.yew.rs/function_router)
|
|
|
|
A blog all about yew.
|
|
The best way to figure out what this example is about is to just open it up.
|
|
It's mobile friendly too!
|
|
|
|
## Concepts
|
|
|
|
This example involves many different parts, here are just the Yew specific things:
|
|
|
|
- Uses [`yew-router`] to render and switch between multiple pages.
|
|
|
|
The example automatically adapts to the `--public-url` value passed to Trunk.
|
|
This allows it to be hosted on any path, not just at the root.
|
|
For example, our demo is hosted at [/router](https://examples.yew.rs/router).
|
|
|
|
This is achieved by adding `<base data-trunk-public-url />` to the [index.html](index.html) file.
|
|
Trunk rewrites this tag to contain the value passed to `--public-url` which can then be retrieved at runtime.
|
|
Take a look at [`Route`](src/main.rs) for the implementation.
|
|
|
|
## Improvements
|
|
|
|
- Use a special image component which shows a progress bar until the image is loaded.
|
|
- Scroll back to the top after switching route
|
|
- Run content generation in a dedicated web worker
|
|
- Use longer Markov chains to achieve more coherent results
|
|
- Make images deterministic (the same seed should produce the same images)
|
|
- Show posts by the author on their page
|
|
(this is currently impossible because we need to find post seeds which in turn generate the author's seed)
|
|
- Show other posts at the end of a post ("continue reading")
|
|
- Home (`/`) should include links to the post list and the author introduction
|
|
- Detect sub-path from `--public-url` value passed to Trunk. See: thedodd/trunk#51
|
|
|
|
[`yew-router`]: https://docs.rs/yew-router/latest/yew_router/
|
|
|
|
## Running
|
|
|
|
Run this application with the trunk development server:
|
|
|
|
```bash
|
|
trunk serve --open
|
|
```
|
|
|
|
### Notes
|
|
|
|
Content generation can take up quite a bit of time in debug builds. It may be better to run this example in release mode if it is slow. |