mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-24 06:43:50 -04:00
Merge branch 'master' into feature/scrollable-content-tabs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -104,7 +104,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
|
||||
|
||||
|
||||
@@ -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)
|
||||
))
|
||||
}
|
||||
|
||||
@@ -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!)
|
||||
|
||||
@@ -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
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user