0

I am trying to update the copyright year in yew wasm (rust). This is the below code I am trying but it does not work unfortunately.

use yew::prelude::*;
use chrono::prelude::*;

#[function_component(Footer)]
pub fn footer() -> Html
{
    let current_date = chrono::Utc::now().date();
    html! 
    {
        <>
            <div class={ "static bottom-0 bg-[#fff] opacity-90 container mx-auto max-w-3xl py-8" }> 
                <footer>
                    <div class={ "flex justify-center space-x-4" }>
                        <h1>{ format!("Copyright {} Name. All Rights Reserved.", current_date.year()) }</h1>
                    </div>
                </footer>
            </div>
        </>
    }
}

I was wondering how do I make this work without getting errors.

I am using trunk serve where in it does not show any errors but the page it self does not load when I use this specific code.

Thamognya
  • 123
  • 1
  • 10
  • 1
    What do you mean by *"it does not work"*? Are you getting compiler errors? Please include them. Or are you getting runtime errors? Or incorrect output? Include that info as well. – kmdreko Jun 20 '22 at 00:36
  • I just use trunk serve. So there are no compiler errors but rather the page does not load. – Thamognya Jun 20 '22 at 00:54

1 Answers1

0

Is your post showing the full program? If not, Can you post it?

In meantime, try to replace the below line:

{ format!("Copyright {} Name. All Rights Reserved.", current_date.year()) }

with this line:

"Copyright {current_date.year()} Name. All Rights Reserved."
AVX-42
  • 755
  • 2
  • 13
  • 21