Absolute URLs in decorateWidget API being rewritten


(Daniel Marquard) #1

This seems like it could be a subdirectory bug. With the code below, a button is generated in the header to the specifications, including in the HTML, but rather than being taken to /donate when clicked, users are instead taken to /community/donate.

api.decorateWidget('header-buttons:after', helper => {
    return helper.attach('link', {
        className: 'btn-primary btn-small login-button donate-button',
        icon: 'paypal',
        rawLabel: "Donate",
        href: "https://critcola.com/donate"
    });
});

(Robin Ward) #2

The link widget is specifically meant to route within the discourse app, so in this case it thinks /donate is a path within the forum. Instead you could just make your link manually like this:

api.decorateWidget('header-buttons:after', helper => {
    return helper.h('a', {
        className: 'btn-primary btn-small login-button donate-button',
        attributes: { href: 'https://critcola.com/donate', target: '_blank' },
    }, [helper.h('i.fa.fa-paypal'), ' Donate'])
});

(Daniel Marquard) #3

Good to know. Thanks!


(Robin Ward) #4