Skip to content

Commit

Permalink
Fixed instant loading (MkDocs 1.2.2 regression)
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Aug 9, 2021
1 parent 3b23896 commit f869d27
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 27 deletions.

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions material/assets/javascripts/bundle.143c17e5.min.js.map

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions material/assets/javascripts/bundle.29db7785.min.js.map

This file was deleted.

2 changes: 1 addition & 1 deletion material/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
</script>
{% endblock %}
{% 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"] %}
<script src="{{ path | url }}"></script>
{% endfor %}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion material/overrides/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
{% endblock %}
{% block scripts %}
{{ super() }}
<script src="{{ 'overrides/assets/javascripts/bundle.dba5ec94.min.js' | url }}"></script>
<script src="{{ 'overrides/assets/javascripts/bundle.25c9f9b3.min.js' | url }}"></script>
{% endblock %}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# IN THE SOFTWARE.

# Direct dependencies
mkdocs>=1.1
mkdocs>=1.2.2
Pygments>=2.4
markdown>=3.2
pymdown-extensions>=7.0
Expand Down
4 changes: 1 addition & 3 deletions src/assets/javascripts/_/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ export interface Config {
*/
const script = getElementOrThrow("#__config")
const config: Config = JSON.parse(script.textContent!)
config.base = new URL(config.base, getLocation())
.toString()
.replace(/\/$/, "")
config.base = new URL(config.base, getLocation()).toString()

/* ----------------------------------------------------------------------------
* Functions
Expand Down
2 changes: 1 addition & 1 deletion src/assets/javascripts/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const print$ = watchPrint()
const config = configuration()
const index$ = document.forms.namedItem("search")
? __search?.index || requestJSON<SearchIndex>(
`${config.base}/search/search_index.json`
new URL("search/search_index.json", config.base)
)
: NEVER

Expand Down
4 changes: 2 additions & 2 deletions src/assets/javascripts/integrations/instant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function preprocess(urls: string[]): string[] {
/* Replace common prefix (i.e. base) with effective base */
const config = configuration()
return urls.map(url => (
url.replace(root.slice(0, index), `${config.base}/`)
url.replace(root.slice(0, index), config.base)
))
}

Expand Down Expand Up @@ -173,7 +173,7 @@ export function setupInstantLoading(
favicon.href = favicon.href

/* Intercept internal navigation */
const push$ = requestXML(`${config.base}/sitemap.xml`)
const push$ = requestXML(new URL("sitemap.xml", config.base))
.pipe(
map(sitemap => preprocess(getElements("loc", sitemap)
.map(node => node.textContent!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function setupSearchWorker(
if (isSearchResultMessage(message)) {
for (const result of message.data.items)
for (const document of result)
document.location = `${config.base}/${document.location}`
document.location = `${new URL(document.location, config.base)}`
}
return message
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function mountIconSearch(
): Observable<Component<IconSearch>> {
const config = configuration()
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 */
Expand Down

0 comments on commit f869d27

Please sign in to comment.