Skip to content

Provide position arguments for navbar placement #98

@christophscheuch

Description

@christophscheuch

Great work so far! It would be nice to have an argument to control the placement of the language dropdown in the navigation bar. Currently, it is always set to the first item in the menu, but I'd love to have it on the right side (even pushed to the end, but I can do this with CSS) on my website. Here is the relevant code:

babelquarto/R/render.R

Lines 462 to 477 in 713dbdb

navbar <- xml2::xml_find_first(html, "//ul[contains(@class, 'navbar-nav')]") # nolint: line_length_linter
navbar_li <- xml2::xml_add_child(
navbar,
"li",
class = "nav-item",
.where = 0L
)
xml2::xml_add_child(
navbar_li,
"div",
class = "dropdown",
id = "languages-links-parent",
.where = "before"
)

I currently use this workaround to change the position via JS:

<script>
document.addEventListener("DOMContentLoaded", function () {
    const langItem = document.getElementById("languages-links-parent");

    const navItem = langItem.closest(".nav-item");
    navItem.parentNode.removeChild(navItem);
  
    const navbar = document.getElementById("navbarCollapse");
    navbar.appendChild(navItem);
  
    navItem.style.marginLeft = "auto";
    navItem.style.display = "flex";
    navItem.style.alignItems = "center";
  });
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions