UNPKG

stackpress

Version:

Incept is a content management framework.

38 lines (37 loc) 949 B
export function paginate(name, skip) { const url = new URL(window.location.href); const search = url.searchParams; search.set(name, String(skip)); window.location.href = url.href; } ; export function order(name) { const url = new URL(window.location.href); const search = url.searchParams; const sort = search.get(name) || ''; const direction = sort === '' ? 'desc' : sort === 'desc' ? 'asc' : ''; if (direction.length > 0) { search.set(name, direction); } else { search.delete(name); } window.location.href = url.href; } ; export function filter(name, value) { const url = new URL(window.location.href); const search = url.searchParams; if (typeof value === 'undefined' || value === null) { search.delete(name); } else { search.set(name, value.toString()); } window.location.href = url.href; } ;