2016-07-22 21:19:10 +02:00

29 lines
590 B
JavaScript

const event = require('../core/event');
const allsettings = require('../core/settings');
const doc = global.window.document;
const settings = Object.assign({
enabled: false
}, allsettings.title);
const onLocationChanged = item => {
const labels = item.getCrumb().map(i => i.label);
let title = labels.join(' > ');
if (labels.length > 1) {
title = labels[labels.length - 1] + ' - ' + title;
}
doc.title = title;
};
const init = () => {
if (!settings.enabled) {
return;
}
event.sub('location.changed', onLocationChanged);
};
init();