render: add pathname to the page context

needed when we need to insert a comment system
This commit is contained in:
Peter Cai 2020-04-14 20:36:00 +08:00
parent 62555714e6
commit 800a39956a
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
1 changed files with 3 additions and 0 deletions

View File

@ -64,6 +64,8 @@ struct PageContext {
// (e.g. the workers.dev domain, which is differnent
// from where you actually deploy the worker)
base_url: String,
// The pathname part of the URL
pathname: String,
// The current query string
query: String
}
@ -148,6 +150,7 @@ fn build_handlebars() -> Handlebars<'static> {
fn build_page_context(url: &Url) -> PageContext {
PageContext {
base_url: url.origin(),
pathname: url.pathname(),
query: url.search()
}
}