Fixed instant loading (MkDocs 1.2.2 regression)

This commit is contained in:
squidfunk 2021-08-09 21:47:49 +02:00
parent 3b23896da3
commit f869d275b4
13 changed files with 25 additions and 27 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -223,7 +223,7 @@
</script> </script>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="{{ 'assets/javascripts/bundle.29db7785.min.js' | url }}"></script> <script src="{{ 'assets/javascripts/bundle.143c17e5.min.js' | url }}"></script>
{% for path in config["extra_javascript"] %} {% for path in config["extra_javascript"] %}
<script src="{{ path | url }}"></script> <script src="{{ path | url }}"></script>
{% endfor %} {% endfor %}

View File

@ -16,5 +16,5 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.dba5ec94.min.js' | url }}"></script> <script src="{{ 'overrides/assets/javascripts/bundle.25c9f9b3.min.js' | url }}"></script>
{% endblock %} {% endblock %}

View File

@ -19,7 +19,7 @@
# IN THE SOFTWARE. # IN THE SOFTWARE.
# Direct dependencies # Direct dependencies
mkdocs>=1.1 mkdocs>=1.2.2
Pygments>=2.4 Pygments>=2.4
markdown>=3.2 markdown>=3.2
pymdown-extensions>=7.0 pymdown-extensions>=7.0

View File

@ -96,9 +96,7 @@ export interface Config {
*/ */
const script = getElementOrThrow("#__config") const script = getElementOrThrow("#__config")
const config: Config = JSON.parse(script.textContent!) const config: Config = JSON.parse(script.textContent!)
config.base = new URL(config.base, getLocation()) config.base = new URL(config.base, getLocation()).toString()
.toString()
.replace(/\/$/, "")
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* Functions * Functions

View File

@ -99,7 +99,7 @@ const print$ = watchPrint()
const config = configuration() const config = configuration()
const index$ = document.forms.namedItem("search") const index$ = document.forms.namedItem("search")
? __search?.index || requestJSON<SearchIndex>( ? __search?.index || requestJSON<SearchIndex>(
`${config.base}/search/search_index.json` new URL("search/search_index.json", config.base)
) )
: NEVER : NEVER

View File

@ -120,7 +120,7 @@ function preprocess(urls: string[]): string[] {
/* Replace common prefix (i.e. base) with effective base */ /* Replace common prefix (i.e. base) with effective base */
const config = configuration() const config = configuration()
return urls.map(url => ( return urls.map(url => (
url.replace(root.slice(0, index), `${config.base}/`) url.replace(root.slice(0, index), config.base)
)) ))
} }
@ -173,7 +173,7 @@ export function setupInstantLoading(
favicon.href = favicon.href favicon.href = favicon.href
/* Intercept internal navigation */ /* Intercept internal navigation */
const push$ = requestXML(`${config.base}/sitemap.xml`) const push$ = requestXML(new URL("sitemap.xml", config.base))
.pipe( .pipe(
map(sitemap => preprocess(getElements("loc", sitemap) map(sitemap => preprocess(getElements("loc", sitemap)
.map(node => node.textContent!) .map(node => node.textContent!)

View File

@ -117,7 +117,7 @@ export function setupSearchWorker(
if (isSearchResultMessage(message)) { if (isSearchResultMessage(message)) {
for (const result of message.data.items) for (const result of message.data.items)
for (const document of result) for (const document of result)
document.location = `${config.base}/${document.location}` document.location = `${new URL(document.location, config.base)}`
} }
return message return message
}), }),

View File

@ -80,7 +80,7 @@ export function mountIconSearch(
): Observable<Component<IconSearch>> { ): Observable<Component<IconSearch>> {
const config = configuration() const config = configuration()
const index$ = requestJSON<IconSearchIndex>( const index$ = requestJSON<IconSearchIndex>(
`${config.base}/overrides/assets/javascripts/iconsearch_index.json` new URL("overrides/assets/javascripts/iconsearch_index.json", config.base)
) )
/* Retrieve query and result components */ /* Retrieve query and result components */