timvink / mkdocs-charts-plugin

Mkdocs plugin to add vegalite charts to your pages
https://timvink.github.io/mkdocs-charts-plugin/
MIT License
80 stars 6 forks source link

loading data from relative path doesn't work on the pages with anchors #24

Closed alsimfer closed 1 month ago

alsimfer commented 1 month ago

Suppose I have a json file and a markdown file in databases folder:

docs/databases/postgresql.md docs/databases/postgres_sqlperf.json

And I want to load it like this:

"data": {"url": "databases/postgres_sqlperf.json"}

Then the data.json will not be loaded, if the chart is referenced by an anchor: http://127.0.0.1:8000/databases/postgresql/#sqlperf

In console I see errors like this

vega@5:1 WARN Loading failed http://127.0.0.1:8000/databases/postgresql/#sqlperf/../../databases/postgres_sqlperf.json SyntaxError: Unexpected token '<', "
<!doctype "... is not valid JSON

The link doesn't work as long as it contains the anchor part. Once I remove it, or load the page by the URL http://127.0.0.1:8000/databases/postgresql/ it works.

Can the plugin strip the anchors before loading the data? Or can it be achieved somehow with the proper configuration? Nothing from the documentation helps in my case.

timvink commented 1 month ago

Thanks for finding this one! Fixed it, soon on pypi..