Skip to content

Commit 3dba3a2

Browse files
author
Erich Wellinger
committed
Add option to specify the homepage uri in your configuration
1 parent 7029609 commit 3dba3a2

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

mkdocs_charts_plugin/plugin.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os
22

3-
from mkdocs.plugins import BasePlugin
43
from mkdocs.config import config_options
54
from mkdocs.exceptions import PluginError
5+
from mkdocs.plugins import BasePlugin
66
from mkdocs.utils import copy_file
77

88
from mkdocs_charts_plugin.fences import fence_vegalite
@@ -23,7 +23,6 @@ def check_library(libnames, dependency):
2323

2424

2525
class 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):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name="mkdocs-charts-plugin",
8-
version="0.0.8",
8+
version="0.0.9",
99
description="MkDocs plugin to add charts from data",
1010
long_description=long_description,
1111
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)