nav: change from data-nav to simple href check

pull/72/head
OFF0 2 years ago
parent 976ea21d52
commit 7abd6fdc6e
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -102,7 +102,7 @@
<!-- views are inserted here --> <!-- views are inserted here -->
</main> </main>
<nav> <nav>
<a data-nav href="/"><span>X</span>feed</a> <a href="/"><span>X</span>feed</a>
<button tpye="button" name="settings">settings</button> <button tpye="button" name="settings">settings</button>
</nav> </nav>
</div> </div>

@ -218,9 +218,9 @@ function createTextNote(evt, relay) {
${evt.tags.length ? `\nTags ${JSON.stringify(evt.tags)}\n` : ''} ${evt.tags.length ? `\nTags ${JSON.stringify(evt.tags)}\n` : ''}
${evt.content}` ${evt.content}`
}, [ }, [
elem('a', {className: `mbox-username${name ? ' mbox-kind0-name' : ''}`, href: `/${evt.nip19.npub}`, data: {nav: true}}, name || userName), elem('a', {className: `mbox-username${name ? ' mbox-kind0-name' : ''}`, href: `/${evt.nip19.npub}`}, name || userName),
' ', ' ',
elem('a', {href: `/${evt.nip19.note}`, data: {nav: true}}, formatTime(time)), elem('a', {href: `/${evt.nip19.note}`}, elem('time', {dateTime: time.toISOString()}, formatTime(time))),
]), ]),
elem('div', {/* data: isLongContent ? {append: evt.content.slice(280)} : null*/}, [ elem('div', {/* data: isLongContent ? {append: evt.content.slice(280)} : null*/}, [
...content, ...content,
@ -421,11 +421,14 @@ window.addEventListener('popstate', (event) => {
}); });
const handleLink = (e, a) => { const handleLink = (e, a) => {
if ('nav' in a.dataset) { const href = a.getAttribute('href');
e.preventDefault(); if (
href === '/'
|| href.startsWith('/note')
|| href.startsWith('/npub')
) {
closeSettingsView(); closeSettingsView();
closePublishView(); closePublishView();
const href = a.getAttribute('href');
route(href); route(href);
history.pushState({}, null, href); history.pushState({}, null, href);
e.preventDefault(); e.preventDefault();

Loading…
Cancel
Save