Added loading of sitemap to filter instant loading requests

This commit is contained in:
squidfunk
2020-05-03 18:02:59 +02:00
committed by Martin Donath
parent 9a0c3e9094
commit 252db1334e
9 changed files with 37 additions and 12 deletions

View File

@@ -100,7 +100,7 @@ interface SetupOptions {
* @param options - Options
*/
export function setupInstantLoading(
{ document$, viewport$, location$ }: SetupOptions
urls: string[], { document$, viewport$, location$ }: SetupOptions
): void {
/* Disable automatic scroll restoration */
@@ -125,7 +125,11 @@ export function setupInstantLoading(
switchMap(ev => {
if (ev.target instanceof HTMLElement) {
const el = ev.target.closest("a")
if (el && !el.target && isLocalLocation(el)) {
if (
el && !el.target &&
isLocalLocation(el) &&
urls.includes(el.href)
) {
if (!isAnchorLocation(el))
ev.preventDefault()
return of(el)