Skip to content

Commit c042b24

Browse files
committed
Fix bug where mkdocs build could have wrong path to print-site CSS and JS, see #62
1 parent 450e087 commit c042b24

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

mkdocs_print_site_plugin/plugin.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,12 @@ def on_template_context(self, context, template_name, config, **kwargs):
253253
# print(f"\nName: {template_name}\nContext: {context.get('extra_css')}")
254254
if template_name == "404.html":
255255
self.context = context
256+
# Make sure paths are OK
257+
if config.get('extra_css'):
258+
self.context['extra_css'] = [get_relative_url(f, self.print_page.file.url) for f in config.get('extra_css')]
259+
if config.get('extra_javascript'):
260+
self.context['extra_javascript'] = [get_relative_url(f, self.print_page.file.url) for f in config.get('extra_javascript')]
261+
256262

257263
def on_post_build(self, config, **kwargs):
258264
"""
@@ -297,6 +303,7 @@ def on_post_build(self, config, **kwargs):
297303

298304
# Get the info for MkDocs to be able to apply a theme template on our print page
299305
env = config["theme"].get_env()
306+
# env.list_templates()
300307
template = env.get_template("main.html")
301308
self.context["page"] = self.print_page
302309
# Render the theme template for the print page

setup.py

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

1010
setup(
1111
name="mkdocs-print-site-plugin",
12-
version="2.2.2",
12+
version="2.2.3",
1313
description="MkDocs plugin that combines all pages into one, allowing for easy export to PDF and standalone HTML.",
1414
long_description=long_description,
1515
long_description_content_type="text/markdown",

0 commit comments

Comments
 (0)