From c042b24a0298aa025539384c58aaca759d45d2fd Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Wed, 12 Jan 2022 14:22:49 +0100 Subject: [PATCH] Fix bug where mkdocs build could have wrong path to print-site CSS and JS, see #62 --- mkdocs_print_site_plugin/plugin.py | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mkdocs_print_site_plugin/plugin.py b/mkdocs_print_site_plugin/plugin.py index 86010bc..a6f2d11 100644 --- a/mkdocs_print_site_plugin/plugin.py +++ b/mkdocs_print_site_plugin/plugin.py @@ -253,6 +253,12 @@ def on_template_context(self, context, template_name, config, **kwargs): # print(f"\nName: {template_name}\nContext: {context.get('extra_css')}") if template_name == "404.html": self.context = context + # Make sure paths are OK + if config.get('extra_css'): + self.context['extra_css'] = [get_relative_url(f, self.print_page.file.url) for f in config.get('extra_css')] + if config.get('extra_javascript'): + self.context['extra_javascript'] = [get_relative_url(f, self.print_page.file.url) for f in config.get('extra_javascript')] + def on_post_build(self, config, **kwargs): """ @@ -297,6 +303,7 @@ def on_post_build(self, config, **kwargs): # Get the info for MkDocs to be able to apply a theme template on our print page env = config["theme"].get_env() + # env.list_templates() template = env.get_template("main.html") self.context["page"] = self.print_page # Render the theme template for the print page diff --git a/setup.py b/setup.py index 8251d01..40aacb9 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name="mkdocs-print-site-plugin", - version="2.2.2", + version="2.2.3", description="MkDocs plugin that combines all pages into one, allowing for easy export to PDF and standalone HTML.", long_description=long_description, long_description_content_type="text/markdown",