Skip to content

Commit 98bb89d

Browse files
committed
add theme option 'pdf_url'
Signed-off-by: Unai Martinez-Corral <[email protected]>
1 parent 6713712 commit 98bb89d

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

sphinx_immaterial/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"search": {},
3333
},
3434
"icon": {},
35+
"pdf_url": "",
3536
"repo_url": "",
3637
"edit_uri": "",
3738
"globaltoc_collapse": True,
@@ -214,6 +215,7 @@ def html_page_context(
214215
"theme": theme_options,
215216
"site_url": theme_options.get("site_url"),
216217
"site_name": context["docstitle"],
218+
"pdf_url": theme_options.get("pdf_url"),
217219
"repo_url": theme_options.get("repo_url"),
218220
"repo_name": theme_options.get("repo_name", None),
219221
"extra": {

sphinx_immaterial/theme.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ repo_name =
5252
# source file. This is typically in the form of 'blob/<branch name>/<docs source folder>'.
5353
edit_uri =
5454

55+
# Relative or absolute location of the PDF
56+
pdf_url =
57+
5558
# Sitemap generation
5659
# Specify a base_url used to generate sitemap.xml links. If not specified, then
5760
# no sitemap will be built.

src/partials/header.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,21 @@
134134
</div>
135135
{% endif %}
136136

137+
<!-- Link to PDF -->
138+
{% if config.pdf_url %}
139+
<div class="md-header__button">
140+
<a
141+
href="{{ config.pdf_url }}"
142+
title="PDF - {{ config.pdf_url }}"
143+
>
144+
<div class="md-icon">
145+
{% set icon = config.theme.icon.pdf or "fontawesome/solid/file-pdf" %}
146+
{% include ".icons/" ~ icon ~ ".svg" %}
147+
</div>
148+
</a>
149+
</div>
150+
{% endif %}
151+
137152
<!-- Button to open search modal -->
138153
{% if "search" in config.plugins %}
139154
<label class="md-header__button md-icon" for="__search">

0 commit comments

Comments
 (0)