Skip to content

Commit 7a814e4

Browse files
author
Erich Wellinger
committed
Tweak how the path to the homepage is determined
1 parent 3dba3a2 commit 7a814e4

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

mkdocs_charts_plugin/plugin.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class ChartsPlugin(BasePlugin):
3131
("vega_renderer", config_options.Type(str, default="svg")),
3232
("vega_width", config_options.Type(str, default="container")),
3333
("fallback_width", config_options.Type(str, default="800")),
34-
("homepage_uri", config_options.Type(str, default="")),
3534
)
3635

3736
def on_config(self, config, **kwargs):
@@ -56,13 +55,6 @@ def on_config(self, config, **kwargs):
5655
check_library(libnames, "vega-lite")
5756
check_library(libnames, "vega-embed")
5857

59-
def on_page_content(self, html, page, config, files, **kwargs):
60-
"""
61-
Store reference to homepage
62-
"""
63-
if page.is_homepage or page.file.src_uri == self.config.get("homepage_uri"):
64-
self.homepage = page.file
65-
6658
def on_post_page(self, output, page, config, **kwargs):
6759
"""
6860
Insert plugin config as javascript variables into the page.
@@ -95,9 +87,11 @@ def add_javascript_variables(self, html, page, config):
9587
"""
9688
plugin_config = self.config.copy()
9789

98-
# Find path to homepage
99-
path_to_homepage = self.homepage.url_relative_to(page.file)
100-
path_to_homepage = os.path.dirname(path_to_homepage)
90+
# Find the path to the homepage
91+
docs_directory = config["docs_dir"]
92+
page_path = os.path.join(docs_directory, page.file.src_uri)
93+
path_to_homepage = os.path.relpath(docs_directory, os.path.dirname(page_path))
94+
10195
if config.get("use_directory_urls"):
10296
path_to_homepage = os.path.join("..", path_to_homepage)
10397
plugin_config["path_to_homepage"] = path_to_homepage

0 commit comments

Comments
 (0)