Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ assert(agentHtml.includes("For AI agents"));
assert(css.includes(".loop-row"));
assert(css.includes(".sort-control"));
assert(browserScript.includes("data-category-filter"));
assert(html.includes('<option value="newest">Newest → oldest</option>'));
assert(html.includes('<option value="oldest">Oldest → newest</option>'));
assert(browserScript.includes('"oldest"'));
assert(browserScript.includes('sortSelect.addEventListener("change"'));
assert(browserScript.includes('params.set("sort", activeSort)'));
assert(browserScript.includes("library-pagination"));
Expand Down
5 changes: 3 additions & 2 deletions site/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
]
}
</script>
<script src="./script.js?v=20260622-sorting" defer></script>
<script src="./script.js?v=20260622-date-directions" defer></script>
<title>Loop Library: Repeatable AI Agent Workflows | Forward Future</title>
</head>
<body>
Expand Down Expand Up @@ -427,7 +427,8 @@ <h2 id="agent-skill-title">
<span>Sort</span>
<select id="loop-sort">
<option value="featured">Featured first</option>
<option value="newest">Newest</option>
<option value="newest">Newest → oldest</option>
<option value="oldest">Oldest → newest</option>
<option value="alphabetical">A–Z</option>
</select>
</label>
Expand Down
25 changes: 23 additions & 2 deletions site/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ const loopTableBody = document.querySelector(".loop-table tbody");
const loopRowPositions = new Map(
loopRows.map((row, index) => [row, index]),
);
const SORT_OPTIONS = new Set(["featured", "newest", "alphabetical"]);
const SORT_OPTIONS = new Set([
"featured",
"newest",
"oldest",
"alphabetical",
]);

let activeSort = "featured";

Expand All @@ -93,6 +98,18 @@ function compareNewest(a, b) {
return loopRowPositions.get(b) - loopRowPositions.get(a);
}

function compareOldest(a, b) {
const publishedDifference = (a.dataset.published ?? "").localeCompare(
b.dataset.published ?? "",
);

if (publishedDifference !== 0) {
return publishedDifference;
}

return loopRowPositions.get(a) - loopRowPositions.get(b);
}

function compareFeatured(a, b) {
const featuredDifference =
Number(b.dataset.featured === "true") -
Expand Down Expand Up @@ -123,7 +140,11 @@ function applySort(sort) {
});
}

return activeSort === "newest" ? compareNewest(a, b) : compareFeatured(a, b);
if (activeSort === "newest") {
return compareNewest(a, b);
}

return activeSort === "oldest" ? compareOldest(a, b) : compareFeatured(a, b);
});

if (loopTableBody) {
Expand Down
Loading