Skip to content

Commit 7d221f4

Browse files
committed
Fix indeterminant sorting in listing tables
Table listings were including the hyperlink `a` tag itself in the contents of the title, meaning that the filter would also apply to the contents of the a tag (for example, the HREF). The weirdness was especially pronounced when testing local previews and filtering with numbers, since the href would often contain port numbers, making the behavior appear random.
1 parent ade956c commit 7d221f4

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/project/types/website/listing/website-listing-template.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,25 @@ export function reshapeListing(
369369
utilities.fieldName = (field: string) => {
370370
return reshaped[kFieldDisplayNames][field] || field;
371371
};
372-
utilities.outputLink = (item: ListingItem, field: string, val?: string) => {
372+
utilities.outputLink = (
373+
item: ListingItem,
374+
field: string,
375+
val?: string,
376+
clz?: string,
377+
) => {
373378
const fieldLinks = reshaped[kFieldLinks];
374379
const value = val || item[field];
375380
const path = item.path;
376381
if (path && value !== undefined && fieldLinks.includes(field)) {
377-
return `<a href="${path}" class="${field}">${value}</a>`;
382+
return `<a href="${path}" class="${field}${
383+
clz ? ` ${clz}` : ""
384+
}">${value}</a>`;
378385
} else {
379-
return value;
386+
if (clz) {
387+
return `<span class="${clz}">${value}</span>`;
388+
} else {
389+
return value;
390+
}
380391
}
381392
};
382393
utilities.sortTarget = (field: string) => {

src/resources/projects/website/listing/listing-table.ejs.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ value = listing.utilities.img(itemNumber, item[field], "", item['image-alt']);
4141
value = listing.utilities.imgPlaceholder(itemNumber, item.outputHref);
4242
}
4343
}
44-
return listing.utilities.outputLink(item, field, value);
44+
return listing.utilities.outputLink(item, field, value, `listing-${field}`);
4545
}
4646
%>
4747

@@ -63,7 +63,7 @@ return listing.utilities.outputLink(item, field, value);
6363

6464
<tr <%= listing.utilities.metadataAttrs(item) %><%= onclick(item) %>>
6565
<% for (const field of fields){ %>
66-
<td class="listing-<%- field %>">
66+
<td>
6767
<%= outputValue(itemNumber, field) %>
6868
</td>
6969
<% } %>

0 commit comments

Comments
 (0)