From 41e9520986a3b9f001a86ed037930c07cd246090 Mon Sep 17 00:00:00 2001 From: Nicola Spadari Date: Fri, 21 Feb 2025 09:40:34 +0100 Subject: [PATCH] Add router options --- app/router.options.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/router.options.ts diff --git a/app/router.options.ts b/app/router.options.ts new file mode 100644 index 0000000..7fe4711 --- /dev/null +++ b/app/router.options.ts @@ -0,0 +1,22 @@ +import type { RouterOptions } from "@nuxt/schema"; + +export default { + scrollBehavior(to, _from, savedPosition) { + return new Promise((resolve, _reject) => { + setTimeout(() => { + if (savedPosition) { + resolve(savedPosition); + } else { + if (to.hash) { + resolve({ + el: to.hash, + top: 0 + }); + } else { + resolve({ top: 0 }); + } + } + }, 100); + }); + } +} satisfies RouterOptions;