Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Generate static routes #34

Open
maccesch opened this issue Apr 28, 2022 · 8 comments
Open

Generate static routes #34

maccesch opened this issue Apr 28, 2022 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@maccesch
Copy link

maccesch commented Apr 28, 2022

Reading routes from dioxus' Router would be nice. These routes should then be generated as static html files when executing dioxus build for a web app.

So a

Link {
    to: "/foo/bar",
}

would generate dist/foo/bar/index.html.

This is what nuxt generate does for example.

Additionally (or maybe as an easier first step) there should be an option in Dioxus.toml what routes are generated.

@mrxiaozhuox
Copy link
Collaborator

so we need check route info and generate the file ?

@mrxiaozhuox
Copy link
Collaborator

but the router is manage with dioxus-router, so we cannot know what we need generate.

@jkelleyrtp
Copy link
Member

Reading routes from dioxus' Router would be nice. These routes should then be generated as static html files when executing dioxus build for a web app.

So a

Link {
    to: "/foo/bar",
}

would generate dist/foo/bar/index.html.

This is what nuxt generate does for example.

Additionally (or maybe as an easier first step) there should be an option in Dioxus.toml what routes are generated.

I actually really like this concept - we could allow a hardcoded list or just look around for the Router component and parse out the contents.

@mrxiaozhuox
Copy link
Collaborator

Reading routes from dioxus' Router would be nice. These routes should then be generated as static html files when executing dioxus build for a web app.
So a

Link {
    to: "/foo/bar",
}

would generate dist/foo/bar/index.html.
This is what nuxt generate does for example.
Additionally (or maybe as an easier first step) there should be an option in Dioxus.toml what routes are generated.

I actually really like this concept - we could allow a hardcoded list or just look around for the Router component and parse out the contents.

but how can we generate the xxx/index.html file

@jkelleyrtp
Copy link
Member

Reading routes from dioxus' Router would be nice. These routes should then be generated as static html files when executing dioxus build for a web app.
So a

Link {
    to: "/foo/bar",
}

would generate dist/foo/bar/index.html.
This is what nuxt generate does for example.
Additionally (or maybe as an easier first step) there should be an option in Dioxus.toml what routes are generated.

I actually really like this concept - we could allow a hardcoded list or just look around for the Router component and parse out the contents.

but how can we generate the xxx/index.html file

A "dumb" way would be to spin up a local dev server and scrape it once the page loaded. A more sophisticated way would be to have an "SSR" entry point in your code (alongside other potential entrypoints) that gets called with some environment-driven context.

fn main_web() {
    dioxus::web::launch(app);
}

fn main_ssr() {
    dioxus::ssr::static_gen(app) // prints to stdout
}

@mrxiaozhuox
Copy link
Collaborator

use dioxus::ssr::static_gen for each page components ?

@jkelleyrtp
Copy link
Member

We don't have a static_gen function yet but I could imagine it would pull from environment variables or stdin or IPC and be commanded by the CLI to generate each page.

@mrxiaozhuox
Copy link
Collaborator

We need to allow the CLI to interact with the program.

@mrxiaozhuox mrxiaozhuox self-assigned this Jul 10, 2022
@mrxiaozhuox mrxiaozhuox added the enhancement New feature or request label Jul 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants