Merge branch 'master' into feature/scrollable-content-tabs

This commit is contained in:
squidfunk
2021-08-09 21:51:27 +02:00
26 changed files with 173 additions and 162 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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!)

View File

@@ -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
}),