Skip to content

Commit

Permalink
Merge pull request #118 from mbasaglia/rename-page
Browse files Browse the repository at this point in the history
Add option to change the print page URL
  • Loading branch information
timvink authored Sep 12, 2024
2 parents cabda6f + 2de2e34 commit d876f02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins:
- print-site:
add_to_navigation: false
print_page_title: 'Print Site'
print_page_basename: 'print_page'
add_print_site_banner: false
# Table of contents
add_table_of_contents: true
Expand All @@ -30,6 +31,9 @@ plugins:
`print_page_title`
: Default is `'Print Site'`. When `add_to_navigation` is set to `true` this setting controls the name of the print page in the navigation of the site. This setting is ignored when `add_to_navigation` is set to `false`.

`print_page_basename`
: Default is `'print_page'`. Can be used to cutomized the path to the print page in the URL.

`add_table_of_contents`
: Default is `true`. Adds a table of contents section at the beginning of the print page (in print version, the HTML version has a different sidebar ToC).

Expand Down
3 changes: 2 additions & 1 deletion mkdocs_print_site_plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class PrintSitePlugin(BasePlugin):
config_scheme = (
("add_to_navigation", config_options.Type(bool, default=False)),
("print_page_title", config_options.Type(str, default="Print Site")),
("print_page_basename", config_options.Type(str, default="print_page")),
("add_table_of_contents", config_options.Type(bool, default=True)),
("toc_title", config_options.Type(str, default="Table of Contents")),
("toc_depth", config_options.Type(int, default=3)),
Expand Down Expand Up @@ -161,7 +162,7 @@ def on_config(self, config, **kwargs):

# Create MkDocs Page and File instances
self.print_file = File(
path="print_page.md",
path=self.config.get("print_page_basename") + ".md",
src_dir="",
dest_dir=config["site_dir"],
use_directory_urls=config.get("use_directory_urls"),
Expand Down

0 comments on commit d876f02

Please sign in to comment.