Skip to content

Commit

Permalink
adding author config variable
Browse files Browse the repository at this point in the history
  • Loading branch information
AakashGfude committed Nov 30, 2023
1 parent 53bf10c commit cab2730
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
31 changes: 24 additions & 7 deletions src/quantecon_book_theme/assets/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]", {
Expand Down
6 changes: 5 additions & 1 deletion src/quantecon_book_theme/assets/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/quantecon_book_theme/theme/quantecon_book_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,17 @@
<p class="qe-page__header-subheading">{{ pagetitle | e }}</p>

</div>
<!-- length 2, since its a string and empty dict has length 2 - {} -->
{%- if theme_authors | length > 2 %}
<p class="qe-page__header-authors">
{% for author in theme_authors %}
<a href="{{ author.url }}" target="_blank"><span>{{ author.name }}</span></a>
{% endfor %}
</p>
{%- else %}
<p class="qe-page__header-authors">{{ author }}</p>
{%- endif %}

<p class="qe-page__header-authors">{{ author }}</p>

</div> <!-- .page__header -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ twitter_logo_url =
og_logo_url =
persistent_sidebar = False
dark_logo =
authors = {}

1 comment on commit cab2730

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.