Thanks for this! I had a need for a set of subcategories to have one act as a redirect. Since my Customize already includes an onPageChange() check already (used to display a header on home page only) this should work as well, and thus is not hard-wired tot the full URL of the site:
<script type="text/discourse-plugin" version="0.8.19">
api.onPageChange((url) => {
// Check if we're on the homepage
if (url === "/" || url === homeRoute) {
// do custom stuff for home page
} else if ( url=== "/c/redirect-politifora" ) {
// category redirect
window.location.replace( "https://politifora.com/" );
} else {
// do stuff on all other pages, if needed
}
});
</script>