Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to change the print page URL #118

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -153,7 +154,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
Loading