@thepassle/app-tools
Version:
Collection of tools I regularly use to build apps. Maybe they're useful to somebody else. Maybe not. Most of these are thin wrappers around native API's, like the native `<dialog>` element, `fetch` API, and `URLPattern`.
14 lines (13 loc) • 339 B
JavaScript
/**
* @param {string|((context: import('../index.js').Context) => string)} path
* @returns {import('../index.js').Plugin}
*/
export function redirect(path) {
return {
name: 'redirect',
shouldNavigate: (context) => ({
condition: () => false,
redirect: typeof path === 'function' ? path(context) : path
})
}
}