Skip to content

Commit

Permalink
add theme option 'pdf_url'
Browse files Browse the repository at this point in the history
Signed-off-by: Unai Martinez-Corral <[email protected]>
  • Loading branch information
umarcor committed May 9, 2023
1 parent 6713712 commit 98bb89d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sphinx_immaterial/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"search": {},
},
"icon": {},
"pdf_url": "",
"repo_url": "",
"edit_uri": "",
"globaltoc_collapse": True,
Expand Down Expand Up @@ -214,6 +215,7 @@ def html_page_context(
"theme": theme_options,
"site_url": theme_options.get("site_url"),
"site_name": context["docstitle"],
"pdf_url": theme_options.get("pdf_url"),
"repo_url": theme_options.get("repo_url"),
"repo_name": theme_options.get("repo_name", None),
"extra": {
Expand Down
3 changes: 3 additions & 0 deletions sphinx_immaterial/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ repo_name =
# source file. This is typically in the form of 'blob/<branch name>/<docs source folder>'.
edit_uri =

# Relative or absolute location of the PDF
pdf_url =

# Sitemap generation
# Specify a base_url used to generate sitemap.xml links. If not specified, then
# no sitemap will be built.
Expand Down
15 changes: 15 additions & 0 deletions src/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,21 @@
</div>
{% endif %}

<!-- Link to PDF -->
{% if config.pdf_url %}
<div class="md-header__button">
<a
href="{{ config.pdf_url }}"
title="PDF - {{ config.pdf_url }}"
>
<div class="md-icon">
{% set icon = config.theme.icon.pdf or "fontawesome/solid/file-pdf" %}
{% include ".icons/" ~ icon ~ ".svg" %}
</div>
</a>
</div>
{% endif %}

<!-- Button to open search modal -->
{% if "search" in config.plugins %}
<label class="md-header__button md-icon" for="__search">
Expand Down

0 comments on commit 98bb89d

Please sign in to comment.