discourse-custom-header-links/common/header.html

39 lines
1004 B
HTML

<script type="text/discourse-plugin" version="0.8.20">
let customHeaderLinks = settings.Custom_header_links;
customHeaderLinks.split("|").map(i => {
let seg = $.map(i.split(","), $.trim),
linkText = seg[0],
linkTitle = seg[1],
linkHref = seg[2],
deviceClass = "." + seg[3],
linkTarget = seg[4] === "self" ? "" : "_blank",
keepOnScrollClass = seg[5] === "keep" ? ".keep" : "";
api.decorateWidget("header-buttons:before", helper => {
return helper.h(
"li.headerLink" + deviceClass + keepOnScrollClass,
helper.h(
"a",
{
href: linkHref,
title: linkTitle,
target: linkTarget,
attributes: { "data-auto-route": "true" }
},
linkText
)
);
});
});
api.decorateWidget("home-logo:after", helper => {
let titleVisible = helper.attrs.minimized;
if (titleVisible) {
$(".d-header").addClass("hide-menus");
} else {
$(".d-header").removeClass("hide-menus");
}
});
</script>