Skip to content

Commit 099c4ee

Browse files
committed
Fix issue found with quoting of sidebar navigation items and missing rel attribute
1 parent e12af3e commit 099c4ee

File tree

5 files changed

+50
-2
lines changed

5 files changed

+50
-2
lines changed

news/changelog-1.5.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ All changes included in 1.5:
6262
- ([#8986](https://github.com/quarto-dev/quarto-cli/issues/8986)): Search: only build subfuse index when it's safe to do so.
6363
- ([#9356](https://github.com/quarto-dev/quarto-cli/issues/9356)): Don't process column classes for figures inside the About divs.
6464
- ([#9781](https://github.com/quarto-dev/quarto-cli/issues/9781)): Correctly hide elements from click event in collapsed margin sidebar.
65+
- Sidebar navigation item now correctly supports `rel` attribute.
66+
- `target` attribute for sidebar navigation items is now correctly inserted with HTML escapes.
6567

6668
## Book
6769

src/resources/projects/website/templates/sidebaritem.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<% if (item.href && item.text && !item.contents) { %>
44
<li class="sidebar-item">
55
<div class="sidebar-item-container">
6-
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%- item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
6+
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%= item.rel ? ` rel="${item.rel}"` : "" %><%= item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
77
</div>
88
</li>
99
<% } else if (item.contents && item.text) { %>
@@ -19,7 +19,7 @@
1919
<% if (item.contents.length > 0) { %>
2020
<div class="sidebar-item-container">
2121
<% if (item.href) { %>
22-
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%- item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
22+
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%= item.rel ? ` rel="${item.rel}"` : "" %><%= item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
2323
<% } else { %>
2424
<a class="sidebar-item-text sidebar-link text-start<%- isCollapsed ? " collapsed" : "" %>" data-bs-toggle="collapse" data-bs-target="#<%- sectionId %>" role="navigation" aria-expanded="<%- isCollapsed ? "false" : "true" %>"><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
2525
<% } %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
_site
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Sidebar-target"
6+
navbar:
7+
left:
8+
- href: index.qmd
9+
text: Home
10+
sidebar:
11+
contents:
12+
- href: https://quarto.org
13+
target: _blank
14+
rel: external
15+
text: Quarto website
16+
- text: PRERELEASE
17+
href: https://prerelease.quarto.org
18+
target: _blank
19+
rel: external
20+
contents:
21+
- href: https://prerelease.quarto.org
22+
target: _blank
23+
rel: external
24+
text: Quarto prerelease website
25+
26+
format: html
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: "Sidebar-target"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'nav#quarto-sidebar a[target="_blank"].sidebar-link'
9+
- 'nav#quarto-sidebar a[rel="external"].sidebar-link'
10+
-
11+
- "nav#quarto-sidebar a[target='\"_blank\"']"
12+
- "nav#quarto-sidebar a[rel='\"external\"']"
13+
- "nav#quarto-sidebar a.sidebar-link:not([rel])"
14+
---
15+
16+
This is a Quarto website.
17+
18+
To learn more about Quarto websites visit <https://quarto.org/docs/websites>.

0 commit comments

Comments
 (0)