-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(www): use
hostname
to load assets for markdown
- Loading branch information
Showing
5 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ serde = "1.0" | |
serde_json = "1.0" | ||
yaml-front-matter = "0.1.0" | ||
wasm-bindgen = "0.2" | ||
web-sys = "0.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod routes; | ||
mod utils; | ||
|
||
use leptos::{component, view, IntoView}; | ||
use leptos_meta::provide_meta_context; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use anyhow::{bail, Context, Result}; | ||
use reqwest::Url; | ||
use web_sys::window; | ||
|
||
pub fn hostname() -> Result<Url> { | ||
if let Some(win) = window() { | ||
let origin_str = win | ||
.location() | ||
.origin() | ||
.map_err(|_| anyhow::anyhow!("Failed to retrieve Origin from Location"))?; | ||
|
||
return Url::parse(&origin_str).context("Failed to parse Origin into URL"); | ||
} | ||
|
||
bail!("Failed to get Window from context") | ||
} |