#include_mdbook macro issue

1 messages · Page 1 of 1 (latest)

haughty lance
#

I'm trying to figure out how to use the include_mdbook crate, but the documentation is very very slim.

I am running dx serve from dx 0.6.0-alpha.2.
How can I create a basic example to embed one page of an mdbook into the frontpage of a Dioxus project? Here is what I tried (assume /docs/en/my-page.md exists from project root):

// main.rs
use dioxus::prelude::*;
use mdbook_macro::mdbook_router;

mdbook_router! {"docs"}

fn main() {
    launch(App);
}

fn App() -> Element {
    rsx! {
        div {
            h1 { "My Dioxus App with mdBook" }
            MyPage {}
        }
    }
}
// Cargo.toml
[package]
... // personal info

[dependencies]
serde = { version = "1.0.197", features = ["derive"] }
dioxus = { git = "https://github.com/dioxuslabs/dioxus", features = [
    "fullstack",
    "router",
] }
use-mdbook = { git = "https://github.com/dioxuslabs/include_mdbook" }
mdbook-macro = { git = "https://github.com/dioxuslabs/include_mdbook" }

[features]
default = []
server = ["dioxus/axum"]
web = ["dioxus/web"]

However, I'm getting this odd error:

error[E0061]: this function takes 5 arguments but 6 arguments were supplied
   --> src/main.rs:7:1
    |
7   | mdbook_router! {"docs"}
    | ^^^^^^^^^^^^^^^^^^^^^^^
    | |
    | unexpected argument #1 of type `&'static str`
    | in this macro invocation
    |
   ::: /home/sebastian/.cargo/git/checkouts/include_mdbook-2ad776093e36b384/dfd4a72/mdbook-macro/src/lib.rs:20:1
    |
20  | pub fn mdbook_router(input: TokenStream) -> TokenStream {
    | ------------------------------------------------------- in this expansion of `mdbook_router!`
    |
note: associated function defined here
   --> /home/sebastian/.cargo/git/checkouts/dioxus-1e619ce595d3799d/20d146d/packages/core/src/hotreload_utils.rs:340:12
    |
340 |     pub fn new(
    |            ^^^

I don't entirely understand, since I'm using the macro as shown in the examples of include_mdbook

sonic minnow
#

the git version of include_mdbook is not using dioxus from git

#

it is using 0.6.0-alpha.2

#

therefore you end up with two versions of dioxus

#

can you use dioxus 0.6.0-alpha.2 instead of using it from git?

haughty lance
#

Thank you! I did that but I'm having a problem with wasm-bindgen as a dependency. Specifically, dx serve is giving the following stdout:

threstderr:i"-runUpdatingkcrates.iokindex\nerror:sfailedrtobselect/aeversion:for the requirement `wasm-bindgen = \"^0.2.95\"`\ncandidate
versionsRfound:whichadidn'tnmatch:r0.2.93\nlocation searched: crates.io index\nrequired by package `web-sys v0.3.72`\n    ... which
satisfies dependency `web-sys = \"^0.3.61\"` (locked to 0.3.72) of package `dioxus-fullstack v0.6.0-alpha.2`\n    ... which satisfies
dependencyi`dioxus-fullstackc= \"^0.6.0-alpha.1\"` (lockedltow0.6.0-alpha.2)nof package

...

} rust wasm file schema version: 0.2.95
     this binary schema version: 0.2.93

Currently the bindgen format is unstable enough that these two schema versions
must exactly match. You can accomplish this by either updating this binary or
the wasm-bindgen dependency in the Rust project.

You should be able to update the wasm-bindgen dependency with:

    cargo update -p wasm-bindgen --precise 0.2.93

don't forget to recompile your wasm file! Alternatively, you can update the
binary with:

    cargo install -f wasm-bindgen-cli --version 0.2.95

I ran both these commands but ran back into the same problem, and the first command gives:
error: failed to select a version for the requirement wasm-bindgen = "^0.2.95"
candidate versions found which didn't match: 0.2.93