Skip to content

Commit d5eff08

Browse files
committed
feat: Add target attribute to links in listing templates if provided
1 parent c1c5a43 commit d5eff08

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/resources/projects/website/listing/item-default.ejs.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ return value;
3232
let value = readField(item, field);
3333
if (value !== undefined) {
3434
print(`<div class="metadata-value listing-${field}">${listing.utilities.outputLink(item, field, value)}</div>`);
35-
}
35+
}
3636
}
3737
%>
3838

@@ -41,7 +41,7 @@ print(`<div class="metadata-value listing-${field}">${listing.utilities.outputLi
4141
<% if (fields.includes('image')) { %>
4242

4343
```{=html}
44-
<div class="thumbnail"><a href="<%- item.path %>" class="no-external">
44+
<div class="thumbnail"><a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="no-external">
4545
<% if (item.image) { %>
4646
<%= listing.utilities.img(itemNumber, item.image, "thumbnail-image", item['image-alt'], item['image-lazy-loading'] ?? listing['image-lazy-loading']) %>
4747
<% } else { %>
@@ -55,9 +55,10 @@ print(`<div class="metadata-value listing-${field}">${listing.utilities.outputLi
5555
::: {.body}
5656

5757
<% if (fields.includes('title')) { %>
58-
<h3 class="no-anchor listing-title"><a href="<%- item.path %>" class="no-external"><%= item.title %></a></h3>
58+
59+
<h3 class="no-anchor listing-title"><a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="no-external"><%= item.title %></a></h3>
5960
<% if (fields.includes('subtitle')) { %>
60-
<div class="listing-subtitle"><a href="<%- item.path %>" class="no-external"><%= item.subtitle %></a></div>
61+
<div class="listing-subtitle"><a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="no-external"><%= item.subtitle %></a></div>
6162
<% } %>
6263
<% } %>
6364

@@ -76,7 +77,7 @@ print(`<div class="metadata-value listing-${field}">${listing.utilities.outputLi
7677
<% if (fields.includes('description')) { %>
7778

7879
```{=html}
79-
<div class="delink listing-description"><a href="<%- item.path %>" class="no-external">
80+
<div class="delink listing-description"><a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="no-external">
8081
```
8182

8283
<%= item.description %>
@@ -92,14 +93,16 @@ print(`<div class="metadata-value listing-${field}">${listing.utilities.outputLi
9293
::: {.metadata}
9394

9495
```{=html}
95-
<a href="<%- item.path %>" class="no-external">
96+
<a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="no-external">
9697
```
9798

9899
<% if (fields.includes('date') && item.date) { %>
100+
99101
<div class="listing-date"><%= item.date %></div>
100102
<% } %>
101103

102104
<% if (fields.includes('author') && item.author) { %>
105+
103106
<div class="listing-author"><%= item.author %></div>
104107
<% } %>
105108

src/resources/projects/website/listing/item-grid.ejs.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ return !["title", "image", "image-alt", "date", "author", "subtitle", "descripti
4040
::: {.g-col-1 <%= listing.utilities.metadataAttrs(item) %> }
4141

4242
```{=html}
43-
<a href="<%- item.path %>" class="quarto-grid-link">
43+
<a href="<%- item.path %>" <%= item.target ? `target="${item.target}"` : "" %> class="quarto-grid-link">
4444
<div class="quarto-grid-item card h-100 <%= `card-${align}` %><%= hideBorders ? ' borderless' : '' %>">
4545
```
4646

@@ -68,10 +68,12 @@ return !["title", "image", "image-alt", "date", "author", "subtitle", "descripti
6868
::: {.card-body .post-contents}
6969

7070
<% if (showField('title')) { %>
71+
7172
<h5 class="no-anchor card-title listing-title"><%= item.title %></h5>
7273
<% } %>
7374

7475
<% if (showField('subtitle')) { %>
76+
7577
<div class="card-subtitle listing-subtitle"><%= item.subtitle %></div>
7678
<% } %>
7779

@@ -120,10 +122,12 @@ const flexJustify = showField('author') && showField('date') ? "justify" : showF
120122
```
121123

122124
<% if (showField('author')) { %>
125+
123126
<div class="listing-author"><%= item.author %></div>
124127
<% } %>
125128

126129
<% if (showField('date')) { %>
130+
127131
<div class="listing-date"><%= item.date %></div>
128132
<% } %>
129133

0 commit comments

Comments
 (0)