mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed relative images not being resolved for instant navigation
This commit is contained in:
parent
bcad9cecd1
commit
a7c71101f9
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -249,7 +249,7 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script src="{{ 'assets/javascripts/bundle.caa56a14.min.js' | url }}"></script>
|
<script src="{{ 'assets/javascripts/bundle.8fd75fb4.min.js' | url }}"></script>
|
||||||
{% for script in config.extra_javascript %}
|
{% for script in config.extra_javascript %}
|
||||||
{{ script | script_tag }}
|
{{ script | script_tag }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -145,16 +145,22 @@ function head(document: Document): Map<string, HTMLElement> {
|
|||||||
/**
|
/**
|
||||||
* Resolve relative URLs in the given document
|
* Resolve relative URLs in the given document
|
||||||
*
|
*
|
||||||
|
* This function resolves relative `href` and `src` attributes, which can belong
|
||||||
|
* to all sorts of tags, like meta tags, links, images, scripts and more.
|
||||||
|
*
|
||||||
* @param document - Document
|
* @param document - Document
|
||||||
*
|
*
|
||||||
* @returns Document observable
|
* @returns Document observable
|
||||||
*/
|
*/
|
||||||
function resolve(document: Document): Observable<Document> {
|
function resolve(document: Document): Observable<Document> {
|
||||||
for (const el of getElements<HTMLLinkElement>("[href], [src]", document))
|
for (const el of getElements("[href], [src]", document))
|
||||||
for (const key in ["href", "src"]) {
|
for (const key of ["href", "src"]) {
|
||||||
const value = el.getAttribute(key)
|
const value = el.getAttribute(key)
|
||||||
if (!/^(?:[a-z]+:)?\/\//i.test(value!))
|
if (value && !/^(?:[a-z]+:)?\/\//i.test(value)) {
|
||||||
el.href = el.href
|
// @ts-expect-error - trick: self-assign to resolve URL
|
||||||
|
el[key] = el[key]
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return document observable
|
// Return document observable
|
||||||
|
Loading…
Reference in New Issue
Block a user