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 <umartinezcorral@antmicro.com>
  • Loading branch information
umarcor committed Nov 21, 2022
1 parent f9d9f5b commit 043ff5f
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 @@ -29,6 +29,7 @@
"search": {},
},
"icon": {},
"pdf_url": "",
"repo_url": "",
"edit_uri": "",
"globaltoc_collapse": True,
Expand Down Expand Up @@ -211,6 +212,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 @@ -54,6 +54,9 @@ repo_type = github
# 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 043ff5f

Please sign in to comment.