Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use builtin date instead of querying meta #218

Merged
merged 2 commits into from
May 4, 2024
Merged
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
47 changes: 16 additions & 31 deletions src/layouts/PatchNotes.astro
Original file line number Diff line number Diff line change
Expand Up @@ -189,37 +189,22 @@ import Base from "./Base.astro";

// Create nav-links

// Query meta, because meta contains the versions in their proper order
fetch("https://meta.quiltmc.org/v3/versions/game")
.then((response) => response.json())
.then((meta) => {
const version2index = {};
var i = 0;
meta.forEach((entry) => {
version2index[entry.version] = i++;
});

data.entries.sort((a,b) => version2index[a.version] - version2index[b.version]);
})
.catch(e => console.warn("Failed to sort versions", e))
.finally(() => {
// Insert the (hopefully sorted) entries into the dom
data.entries.forEach((entry) => {
const listItem = document.createElement("li");
const newRef = document.createElement("a");

newRef.classList.add("version-item");
newRef.id = "button-"+entry.version;
newRef.innerText = entry.version;
newRef.setAttribute(
"href",
window.location.pathname + "#" + entry.version
);

listItem.appendChild(newRef);
document.getElementById("sidebar").appendChild(listItem);
});
});
data.entries.sort((a,b) => Date.parse(b.date) - Date.parse(a.date));
data.entries.forEach((entry) => {
const listItem = document.createElement("li");
const newRef = document.createElement("a");

newRef.classList.add("version-item");
newRef.id = "button-"+entry.version;
newRef.innerText = entry.version;
newRef.setAttribute(
"href",
window.location.pathname + "#" + entry.version
);

listItem.appendChild(newRef);
document.getElementById("sidebar").appendChild(listItem);
});

// Rerender the patch note when the url changes
window.onhashchange = render;
Expand Down