const m = require('mithril') const Authentication = require('./authentication') const Header = { oninit: function(vnode) { this.currentActive = 'home' this.error = '' this.loading = false this.onbeforeupdate() }, onbeforeupdate: function() { let currentPath = m.route.get() console.log(currentPath) if (currentPath === '/') this.currentActive = 'home' else if (currentPath === '/login') this.currentActive = 'login' }, logOut: function() { Authentication.clearToken() m.route.set('/') }, view: function() { return [ m(m.route.Link, { href: '/', class: 'title' }, [ m('img.logo', { src: '/assets/img/logo.svg' }), ] ), m('div.filler'), m('div.links', [ m(m.route.Link, { href: '/#Heim' }, 'Heim'), m(m.route.Link, { href: '/#GoodAdvice' }, 'Góð ráð'), m(m.route.Link, { class: 'button', href: '/#Subscribe' }, 'Subscribe'), ]), ] }, } module.exports = Header