From 942b48000d25d6baac7379cdc1ce627590efd7b5 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 27 Sep 2023 13:12:17 +0100 Subject: [PATCH] fix: scroll to location.hash after load (fixes WEB-4) --- src/ts/app.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ts/app.ts b/src/ts/app.ts index 3daa3f2..968fa29 100644 --- a/src/ts/app.ts +++ b/src/ts/app.ts @@ -53,6 +53,13 @@ declare const Prism: any; API.getBlogPost(id).then((post) => { blogPost.innerHTML = post.content; UI.updateUI(blogPost); + + if (location.hash && location.hash !== '#' && location.hash.startsWith('#')) { + const element = document.querySelector(location.hash); + if (element) { + setTimeout(() => element.scrollIntoView(), 1000); + } + } }); }