From cbffa2a3409ddf27f88ef489bb81f5d9b907a201 Mon Sep 17 00:00:00 2001 From: Sarah German Date: Mon, 14 Aug 2023 21:38:11 +0000 Subject: Scroll to search query on result pages --- content/assets/stylesheets/stylesheet.scss | 5 ++ .../frontend/search/components/lunr_results.vue | 7 ++- content/frontend/search/google.js | 3 +- content/frontend/search/lunrsearch.js | 42 +++++++++-------- content/frontend/search/search_helpers.js | 55 ++++++++++++++++++++++ content/frontend/services/google_search_api.js | 7 ++- spec/frontend/search/search_helper_spec.js | 32 +++++++++++++ 7 files changed, 128 insertions(+), 23 deletions(-) create mode 100644 spec/frontend/search/search_helper_spec.js diff --git a/content/assets/stylesheets/stylesheet.scss b/content/assets/stylesheets/stylesheet.scss index 751c5b18..ebaa60bd 100644 --- a/content/assets/stylesheets/stylesheet.scss +++ b/content/assets/stylesheets/stylesheet.scss @@ -20,6 +20,11 @@ body { } } +h2, +h3, +h4, +h5, +h6, :target { scroll-margin-top: $header-height + 1rem; } diff --git a/content/frontend/search/components/lunr_results.vue b/content/frontend/search/components/lunr_results.vue index 7d147127..f579938d 100644 --- a/content/frontend/search/components/lunr_results.vue +++ b/content/frontend/search/components/lunr_results.vue @@ -1,7 +1,7 @@