Skip to content

Commit

Permalink
Merge pull request godotengine#6407 from YuriSizov/frontend-remove-se…
Browse files Browse the repository at this point in the history
…arch-highlight

Remove search highlights from the page and the history
  • Loading branch information
YuriSizov authored Nov 21, 2022
2 parents 6209300 + 0209919 commit b3f571c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion _static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -1106,12 +1106,21 @@ kbd.compound > .kbd,
background-color: var(--navbar-current-background-color-active);
}

/* Hide the obnoxious automatic highlight in search results */
/* Hide the obnoxious automatic highlight from the search context. */
.rst-content .highlighted {
background-color: transparent;
box-shadow: none;
font-weight: inherit;
padding: 0;
}
/* Still slightly highlight matched parts on the dedicated search results page. */
.rst-content #search-results .highlighted {
background-color: #ffcd0029;
border-radius: 2px;
color: var(--body-color);
font-weight: 600;
padding: 0 3px;
}

/* Allows the scrollbar to be shown in the sidebar */
@media only screen and (min-width: 769px) {
Expand Down
8 changes: 8 additions & 0 deletions _static/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ const registerSidebarObserver = (function(){
})();

$(document).ready(() => {
// Remove the search match highlights from the page, and adjust the URL in the
// navigation history.
const url = new URL(location.href);
if (url.searchParams.has('highlight')) {
Documentation.hideSearchWords();
}

// Initialize handlers for page scrolling and our custom sidebar.
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');

registerOnScrollEvent(mediaQuery);
Expand Down
4 changes: 2 additions & 2 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,14 @@
html_css_files = [
'css/algolia.css',
'https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css',
"css/custom.css?2", # Increment the number at the end when the file changes to bust the cache.
"css/custom.css?3", # Increment the number at the end when the file changes to bust the cache.
]

if not on_rtd:
html_css_files.append("css/dev.css")

html_js_files = [
"js/custom.js?1", # Increment the number at the end when the file changes to bust the cache.
"js/custom.js?2", # Increment the number at the end when the file changes to bust the cache.
('https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js', {'defer': 'defer'}),
('js/algolia.js', {'defer': 'defer'})
]
Expand Down

0 comments on commit b3f571c

Please sign in to comment.