mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-11-24 07:30:12 +01:00
Added automatic removal of query parameter when search is closed
This commit is contained in:
parent
5acd0c3620
commit
e3c26215de
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -213,7 +213,7 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ 'assets/javascripts/bundle.8aa65030.min.js' | url }}"></script>
|
||||
<script src="{{ 'assets/javascripts/bundle.cd6d3f86.min.js' | url }}"></script>
|
||||
{% for path in config["extra_javascript"] %}
|
||||
<script src="{{ path | url }}"></script>
|
||||
{% endfor %}
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -16,5 +16,5 @@
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script src="{{ 'overrides/assets/javascripts/bundle.90528257.min.js' | url }}"></script>
|
||||
<script src="{{ 'overrides/assets/javascripts/bundle.068fb875.min.js' | url }}"></script>
|
||||
{% endblock %}
|
||||
|
@ -44,7 +44,8 @@ import { translation } from "~/_"
|
||||
import {
|
||||
getLocation,
|
||||
setToggle,
|
||||
watchElementFocus
|
||||
watchElementFocus,
|
||||
watchToggle
|
||||
} from "~/browser"
|
||||
import {
|
||||
SearchMessageType,
|
||||
@ -101,6 +102,18 @@ export function watchSearchQuery(
|
||||
map(() => searchParams.get("q") || "")
|
||||
)
|
||||
|
||||
/* Remove query parameter when search is closed */
|
||||
watchToggle("search")
|
||||
.pipe(
|
||||
filter(active => !active),
|
||||
take(1)
|
||||
)
|
||||
.subscribe(() => {
|
||||
const url = new URL(location.href)
|
||||
url.searchParams.delete("q")
|
||||
history.replaceState({}, "", `${url}`)
|
||||
})
|
||||
|
||||
/* Set query from parameter */
|
||||
param$.subscribe(value => { // TODO: not ideal - find a better way
|
||||
if (value)
|
||||
|
@ -84,7 +84,7 @@ export function mountIconSearchQuery(
|
||||
)
|
||||
.subscribe(([, value]) => {
|
||||
const path = document.location.pathname
|
||||
if (value.length)
|
||||
if (typeof ga === "function" && value.length)
|
||||
ga("send", "pageview", `${path}?q=[icon]+${value}`)
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user