Added loading of sitemap to filter instant loading requests #1668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a fix attempt for #1653. When instant loading is enabled, the current
master
will intercept all links that are relative to thebase_url
and assume that they can be loaded via XHR. However, as described in the linked issue, static pages may be included as part of the build, but not part of the documentation as such. For this reason, we need a way to distinguish URLs to be loaded via instant loading.With this PR, before setting up instant loading, the
sitemap.xml
is fetched, which is built by MkDocs and includes all URLs to all documents that are part of the navigation tree. Before dispatching via XHR, the application now checks whether the URL is part of this list. If it is part of the list, the request is loaded via XHR, if it isn't, it is dispatched regularly.As this is a pretty fundamental change, I'd want to get some feedback before merging this into
master
. Also, locally, the URL must now match the development server host, or instant loading won't work, e.g. when the docs are served with-a 0.0.0.0
, URLs includinglocalhost
won't be dispatched. If somebody has a good idea of how to get a canonical URL out of all the different localhost stuff, I'd be happy to integrate it.