nav: change from data-nav to simple href check

OFF0 2 years ago
parent ad7ad36581
commit a313b9449a
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

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

@ -218,9 +218,9 @@ function createTextNote(evt, relay) {
${evt.tags.length ? `\nTags ${JSON.stringify(evt.tags)}\n` : ''}
${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*/}, [
...content,
@ -421,11 +421,14 @@ window.addEventListener('popstate', (event) => {
});
const handleLink = (e, a) => {
if ('nav' in a.dataset) {
e.preventDefault();
const href = a.getAttribute('href');
if (
href === '/'
|| href.startsWith('/note')
|| href.startsWith('/npub')
) {
closeSettingsView();
closePublishView();
const href = a.getAttribute('href');
route(href);
history.pushState({}, null, href);
e.preventDefault();

Loading…
Cancel
Save