11import os
22
3- from mkdocs .plugins import BasePlugin
43from mkdocs .config import config_options
54from mkdocs .exceptions import PluginError
5+ from mkdocs .plugins import BasePlugin
66from mkdocs .utils import copy_file
77
88from mkdocs_charts_plugin .fences import fence_vegalite
@@ -23,7 +23,6 @@ def check_library(libnames, dependency):
2323
2424
2525class ChartsPlugin (BasePlugin ):
26-
2726 config_scheme = (
2827 ("data_path" , config_options .Type (str , default = "" )),
2928 ("use_data_path" , config_options .Type (bool , default = True )),
@@ -32,6 +31,7 @@ class ChartsPlugin(BasePlugin):
3231 ("vega_renderer" , config_options .Type (str , default = "svg" )),
3332 ("vega_width" , config_options .Type (str , default = "container" )),
3433 ("fallback_width" , config_options .Type (str , default = "800" )),
34+ ("homepage_uri" , config_options .Type (str , default = "" )),
3535 )
3636
3737 def on_config (self , config , ** kwargs ):
@@ -41,16 +41,10 @@ def on_config(self, config, **kwargs):
4141 """
4242 # Add pointer to mkdocs-charts-plugin.js
4343 # which is added to the output directory during on_post_build() event
44- config ["extra_javascript" ] = ["js/mkdocs-charts-plugin.js" ] + config [
45- "extra_javascript"
46- ]
44+ config ["extra_javascript" ] = ["js/mkdocs-charts-plugin.js" ] + config ["extra_javascript" ]
4745
4846 # Make sure custom fences are configured.
49- custom_fences = (
50- config .get ("mdx_configs" , {})
51- .get ("pymdownx.superfences" , {})
52- .get ("custom_fences" , {})
53- )
47+ custom_fences = config .get ("mdx_configs" , {}).get ("pymdownx.superfences" , {}).get ("custom_fences" , {})
5448 if not custom_fences :
5549 raise PluginError (
5650 "[mkdocs_charts_plugin]: You have not configured any custom fences, please see the setup instructions."
@@ -66,7 +60,7 @@ def on_page_content(self, html, page, config, files, **kwargs):
6660 """
6761 Store reference to homepage
6862 """
69- if page .is_homepage :
63+ if page .is_homepage or page . file . src_uri == self . config . get ( "homepage_uri" ) :
7064 self .homepage = page .file
7165
7266 def on_post_page (self , output , page , config , ** kwargs ):
0 commit comments