Skip to content

Commit 896f62a

Browse files
authored
Add trailing slash to site_url
`site_url` has to end with a trailing slash, because when MkDocs processes the Jinja2 templates, it will embed a script tag into the final html: ```js <script id="__config" type="application/json">{"base": "/some/path/4.1.1", ...}</script> ``` The JS-relevant part of mike then handles this as follows `fetch(ABS_BASE_URL + "../versions.json")` or, if you look at the actual js-bundle: `new URL("../versions.json", t.base)` And if `t.base` doesn't end with a trailing slash, the last component is completely ignored, which is obviously not what we want.
1 parent 97deaed commit 896f62a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mike/mkdocs_plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def on_config(self, config):
4646
if version and config.get('site_url'):
4747
if self.config['canonical_version'] is not None:
4848
version = self.config['canonical_version']
49-
config['site_url'] = urljoin(config['site_url'], version)
49+
config['site_url'] = urljoin(config['site_url'], version) + '/'
5050

5151
def on_files(self, files, config):
5252
if not self.config['version_selector']:

0 commit comments

Comments
 (0)