From d1654c35ae042c6c8144f50528639cdffc541a16 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 12 Oct 2018 21:08:41 +0200 Subject: [PATCH] theme: make it possible to add JS files and arbitrary HTML to page head. --- doc/pelican/theme.rst | 19 ++++++++++++++++--- pelican-theme/templates/base.html | 2 ++ pelican-theme/templates/page.html | 12 ++++++++++++ pelican-theme/test/page_extra_css/page.rst | 5 ----- .../page.html | 5 +++++ .../test/page_extra_html_head/page.rst | 13 +++++++++++++ pelican-theme/test/test_page.py | 7 ++++--- 7 files changed, 52 insertions(+), 11 deletions(-) delete mode 100644 pelican-theme/test/page_extra_css/page.rst rename pelican-theme/test/{page_extra_css => page_extra_html_head}/page.html (84%) create mode 100644 pelican-theme/test/page_extra_html_head/page.rst diff --git a/doc/pelican/theme.rst b/doc/pelican/theme.rst index c7603cd8..478757b0 100644 --- a/doc/pelican/theme.rst +++ b/doc/pelican/theme.rst @@ -337,11 +337,15 @@ Pages can override which menu item in the `top navbar`_ will be highlighted by specifying the corresponding menu item slug in the :rst:`:highlight:` field. If the field is not present, page's own slug is used instead. -`Extra CSS`_ ------------- +`Extending HTML \`_ +-------------------------- The :rst:`:css:` field can be used to link additional CSS files in page header. -Put one URL per line, internal link targets are expanded. Example: +Put one URL per line, internal link targets are expanded. Similarly :rst:`:js:` +can be used to link JavaScript files. Besides that, the :rst:`:html_header:` +field can be used to put arbitrary HTML at the end of the :html:`` +element. Indenting the lines is possible by putting an escaped space in front +(the backslash and the escaped space itself won't get inserted). Example: .. code:: rst @@ -351,6 +355,15 @@ Put one URL per line, internal link targets are expanded. Example: :css: {filename}/static/webgl.css {filename}/static/canvas-controls.css + :js: + {filename}/static/showcase.js + :html_header: + `Breadcrumb navigation`_ ------------------------ diff --git a/pelican-theme/templates/base.html b/pelican-theme/templates/base.html index 9c9930d7..de99b0de 100644 --- a/pelican-theme/templates/base.html +++ b/pelican-theme/templates/base.html @@ -36,6 +36,8 @@ {% block social %} {% endblock social %} {% endif %} + {% block extra %} + {% endblock extra %}