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>
|
||||
{% endblock %}
|
||||
{% 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 %}
|
||||
{{ script | script_tag }}
|
||||
{% endfor %}
|
||||
|
@ -145,16 +145,22 @@ function head(document: Document): Map<string, HTMLElement> {
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @returns Document observable
|
||||
*/
|
||||
function resolve(document: Document): Observable<Document> {
|
||||
for (const el of getElements<HTMLLinkElement>("[href], [src]", document))
|
||||
for (const key in ["href", "src"]) {
|
||||
for (const el of getElements("[href], [src]", document))
|
||||
for (const key of ["href", "src"]) {
|
||||
const value = el.getAttribute(key)
|
||||
if (!/^(?:[a-z]+:)?\/\//i.test(value!))
|
||||
el.href = el.href
|
||||
if (value && !/^(?:[a-z]+:)?\/\//i.test(value)) {
|
||||
// @ts-expect-error - trick: self-assign to resolve URL
|
||||
el[key] = el[key]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Return document observable
|
||||
|
Loading…
Reference in New Issue
Block a user