Allow the `href` setting to be a function.
This commit is contained in:
parent
a244c33023
commit
1ac6dd194d
|
@ -11,6 +11,11 @@ export default createWidget('home-logo', {
|
||||||
href: '/'
|
href: '/'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
href() {
|
||||||
|
const href = this.settings.href;
|
||||||
|
return (typeof href === "function") ? href() : href;
|
||||||
|
},
|
||||||
|
|
||||||
logo() {
|
logo() {
|
||||||
const { siteSettings } = this;
|
const { siteSettings } = this;
|
||||||
const mobileView = this.site.mobileView;
|
const mobileView = this.site.mobileView;
|
||||||
|
@ -38,13 +43,13 @@ export default createWidget('home-logo', {
|
||||||
},
|
},
|
||||||
|
|
||||||
html() {
|
html() {
|
||||||
return h('a', { attributes: { href: this.settings.href } }, this.logo());
|
return h('a', { attributes: { href: this.href(), 'data-auto-route': true } }, this.logo());
|
||||||
},
|
},
|
||||||
|
|
||||||
click(e) {
|
click(e) {
|
||||||
if (wantsNewWindow(e)) { return false; }
|
if (wantsNewWindow(e)) { return false; }
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
DiscourseURL.routeTo(this.settings.href);
|
DiscourseURL.routeTo(this.href());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue