Skip to content

Commit f94dea3

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

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
@@ -30,6 +30,7 @@
3030
"search": {},
3131
},
3232
"icon": {},
33+
"pdf_url": "",
3334
"repo_url": "",
3435
"edit_uri": "",
3536
"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
@@ -54,6 +54,9 @@ repo_type = github
5454
# source file. This is typically in the form of 'blob/<branch name>/<docs source folder>'.
5555
edit_uri =
5656

57+
# Relative or absolute location of the PDF
58+
pdf_url =
59+
5760
# Sitemap generation
5861
# Specify a base_url used to generate sitemap.xml links. If not specified, then
5962
# 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)