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

Automate major version change on home page #434

Closed
wants to merge 2 commits into from
Closed
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
37 changes: 25 additions & 12 deletions home.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,29 @@
</div>

<script>
window.onload = async function () {
// Get the latest version of sunpy from PyPI
const res = await fetch("https://pypi.org/pypi/sunpy/json");
const data = await res.json();
document.getElementById("version").innerHTML = data.info.version;

// Pride month
const d = new Date();
if (d.getMonth() == 5) {
document.getElementById("logo").src = "_static/img/pride/sunpy_icon.svg";
}
};
window.onload = async function () {
// Fetch SunPy version from PyPI
const res = await fetch("https://pypi.org/pypi/sunpy/json");
if (!res.ok) return;
const data = await res.json();

// Extract the version and update the "Latest stable release"
const latestVersion = data.info.version;
document.getElementById("version").innerHTML = latestVersion;

// Extract the major version and update the "What's new in x.y?" section
const majorVersion = latestVersion.split(".")[0]; // Get the first part (major version)
const whatsNewLink = `https://docs.sunpy.org/en/stable/whatsnew/${majorVersion}.0.html`;
const whatsNewText = `What's new in sunpy ${majorVersion}.0?`;
const whatsNewElement = document.querySelector(".whatsnew a");
whatsNewElement.href = whatsNewLink;
whatsNewElement.innerHTML = whatsNewText;

// Special case for Pride month (June)
const d = new Date();
if (d.getMonth() == 5) {
document.getElementById("logo").src = "_static/img/pride/sunpy_icon.svg";
}
};

</script>
Loading