Skip to content

Commit af37a71

Browse files
committed
fix: ensure "target" is not displayed in listing
1 parent 6dfc209 commit af37a71

7 files changed

Lines changed: 75 additions & 13 deletions

File tree

‎src/project/types/website/listing/website-listing-read.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ function hydrateListing(
557557
// If the items have come from metadata, we should just show
558558
// all the columns in the table. Otherwise, we should use the
559559
// document default columns
560-
const undisplayable = ["path"];
560+
const undisplayable = ["path", "target"];
561561
return itemFields.filter((field) => {
562562
return !undisplayable.includes(field);
563563
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
listing:
3+
type: default
4+
contents:
5+
- title: "Post with target"
6+
path: posts/post-with-target.qmd
7+
target: "_blank"
8+
- title: "Post without target"
9+
path: posts/post-without-target.qmd
10+
_quarto:
11+
tests:
12+
html:
13+
ensureHtmlElements:
14+
-
15+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
16+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
17+
ensureHtmlElementCount:
18+
selectors: ['.listing-target']
19+
counts: [0]
20+
---
21+
22+
## Default listing with metadata specification test

‎tests/docs/smoke-all/listings/target-attribute/index-default.qmd‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
listing:
33
type: default
44
contents: posts/*.qmd
5-
fields:
6-
- title
75
_quarto:
86
tests:
97
html:
108
ensureHtmlElements:
119
-
12-
- "a[href$='post-with-target.html'][target='_blank']"
13-
- "a[href$='post-without-target.html']:not([target])"
10+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
11+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
1412
---
1513

1614
## Default listing with target attribute test
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
listing:
3+
type: grid
4+
contents:
5+
- title: "Post with target"
6+
path: posts/post-with-target.qmd
7+
target: "_blank"
8+
- title: "Post without target"
9+
path: posts/post-without-target.qmd
10+
_quarto:
11+
tests:
12+
html:
13+
ensureHtmlElements:
14+
-
15+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
16+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
17+
ensureHtmlElementCount:
18+
selectors: ['.listing-target']
19+
counts: [0]
20+
---
21+
22+
## Grid listing with metadata specification test

‎tests/docs/smoke-all/listings/target-attribute/index-grid.qmd‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
listing:
33
type: grid
44
contents: posts/*.qmd
5-
fields:
6-
- title
75
_quarto:
86
tests:
97
html:
108
ensureHtmlElements:
119
-
12-
- "a[href$='post-with-target.html'][target='_blank']"
13-
- "a[href$='post-without-target.html']:not([target])"
10+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
11+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
1412
---
1513

1614
## Grid listing with target attribute test
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
listing:
3+
type: table
4+
contents:
5+
- title: "Post with target"
6+
path: posts/post-with-target.qmd
7+
target: "_blank"
8+
- title: "Post without target"
9+
path: posts/post-without-target.qmd
10+
table-hover: true
11+
_quarto:
12+
tests:
13+
html:
14+
ensureHtmlElements:
15+
-
16+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
17+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
18+
- "tr[onclick*='window.open']"
19+
ensureHtmlElementCount:
20+
selectors: ['.listing-target']
21+
counts: [0]
22+
---
23+
24+
## Table listing with metadata specification test

‎tests/docs/smoke-all/listings/target-attribute/index-table.qmd‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
listing:
33
type: table
44
contents: posts/*.qmd
5-
fields:
6-
- title
75
table-hover: true
86
_quarto:
97
tests:
108
html:
119
ensureHtmlElements:
1210
-
13-
- "a[href$='post-with-target.html'][target='_blank']"
14-
- "a[href$='post-without-target.html']:not([target])"
11+
- "a[href$='post-with-target.html'][target='_blank'][rel='noopener']"
12+
- "a[href$='post-without-target.html']:not([target]):not([rel])"
1513
- "tr[onclick*='window.open']"
1614
---
1715

0 commit comments

Comments
 (0)