Problem: search results have edit link while on read side
All checks were successful
continuous-integration/drone/push Build is passing

Solution: only use /edit/ link when editing
This commit is contained in:
Peter Stuifzand 2022-01-15 02:04:49 +01:00
parent 1115fa14ff
commit d569fd560f

View File

@ -121,6 +121,8 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
selectedPos = $lc.find('li').index(selected[0])
}
const isEditing = window.location.pathname.match(/^\/edit\//)
let $ul = el('ul',
_.map(results, (hit, i) => {
let div = el('div', []);
@ -133,7 +135,7 @@ function showSearchResultsExtended(element, template, searchTool, query, input,
];
if (hit.ref) {
children = hit.ref ? [el('a', children)] : children;
children[0].setAttribute('href', '/edit/' + hit.ref)
children[0].setAttribute('href', (isEditing ? '/edit/' : '/') + hit.ref)
}
const li = el('li', children)
if (selectedPos === i) li.classList.add('selected')