Skip to content

Support Single Page Applications (SPA) for addons that depend on the URL #157

@humitos

Description

@humitos

Material for MkDocs and other doctools (I think that Docusaurus too) implement a feature that load the content of the page without making a regular request to the server 1:

When instant loading is enabled, clicks on all internal links will be intercepted and dispatched via XHR without fully reloading the page.

This makes addons that depend on the actual URL to not work as expected (e.g. docdiff). When loading the page, the addons API is hit with url= but then the user clicks on an internal link, which uses the instant reload feature to load the page content but our addons doesn't do another request with the url= field updated, making docdiff to use the old URL to compare against.

I think we could listen to an event to check if the URL has changed and if so, make a request to the addons API again with the updated url= attribute. It seems there is a navigator API to do this, but it's experimental for now, tho: https://developer.mozilla.org/en-US/docs/Web/API/Navigation_API

Footnotes

  1. https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#instant-loading

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions