Skip to content
Draft
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
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