diff --git a/src/quantecon_book_theme/assets/scripts/index.js b/src/quantecon_book_theme/assets/scripts/index.js index 2975b4a..4d5652d 100644 --- a/src/quantecon_book_theme/assets/scripts/index.js +++ b/src/quantecon_book_theme/assets/scripts/index.js @@ -376,17 +376,34 @@ document.addEventListener("DOMContentLoaded", function () { ); })(); + /** + * Add authors to the heading of toc page + */ (function () { const authors = document.getElementsByClassName( "qe-page__header-authors", - )[0].innerText; - // adding authors to the page - if (authors) { - const h1a = document.querySelector("h1 a"); - const newParagraph = document.createElement("p"); - newParagraph.textContent = authors; - h1a.insertAdjacentElement("afterend", newParagraph); + )[0]; + + const h1 = document.querySelector(".main-index h1"); + + // check if its the main toc page + if (!h1) { + return; + } + // creating a p tag for styling and author links + const newParagraph = document.createElement("p"); + newParagraph.setAttribute("id", "qe-page-author-links"); + + //check if there are authors + const isAuthor = + authors && + authors.querySelectorAll("a").length && + authors.querySelectorAll("a")[0].innerText !== ""; + if (isAuthor) { + newParagraph.innerHTML = authors.innerHTML; } + // insert p tag after h1, even if no authors for styling + h1.insertAdjacentElement("afterend", newParagraph); })(); // Tooltips tippy("[data-tippy-content]", { diff --git a/src/quantecon_book_theme/assets/styles/index.scss b/src/quantecon_book_theme/assets/styles/index.scss index ca0923a..490765d 100644 --- a/src/quantecon_book_theme/assets/styles/index.scss +++ b/src/quantecon_book_theme/assets/styles/index.scss @@ -759,10 +759,14 @@ tt { .main-index { h1 { + font-weight: 700; + margin-bottom: 0px; + padding: 0 0 1rem 0; + } + #qe-page-author-links { border-bottom: 5px solid #0072bc; margin: 0 0 2rem 0; padding: 0 0 1rem 0; - font-weight: 700; } } diff --git a/src/quantecon_book_theme/theme/quantecon_book_theme/layout.html b/src/quantecon_book_theme/theme/quantecon_book_theme/layout.html index 964b99a..d28801a 100644 --- a/src/quantecon_book_theme/theme/quantecon_book_theme/layout.html +++ b/src/quantecon_book_theme/theme/quantecon_book_theme/layout.html @@ -148,8 +148,17 @@

{{ pagetitle | e }}

+ + {%- if theme_authors | length > 2 %} +

+ {% for author in theme_authors %} + {{ author.name }} + {% endfor %} +

+ {%- else %} +

{{ author }}

+ {%- endif %} -

{{ author }}

diff --git a/src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf b/src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf index 6d022ee..3a8d74a 100644 --- a/src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf +++ b/src/quantecon_book_theme/theme/quantecon_book_theme/theme.conf @@ -29,3 +29,4 @@ twitter_logo_url = og_logo_url = persistent_sidebar = False dark_logo = +authors = {}