Skip to content

Commit

Permalink
Add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
bboonstra committed Oct 22, 2024
1 parent de974b0 commit 1e1fbc9
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 0 deletions.
81 changes: 81 additions & 0 deletions docs/changelog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#changelog-content {
max-width: 800px;
margin: 0 auto;
padding: 20px;
font-family: var(--body-font);
color: var(--text-color);
background-color: var(--background-color);
text-align: center;
}

#changelog-content h1 {
color: var(--primary-color);
border-bottom: 2px solid var(--primary-color);
padding-bottom: 10px;
margin-bottom: 20px;
}

#changelog-content h2 {
color: var(--background-color);
background-color: var(--primary-color);
font-size: 2.25rem;
padding: 10px 20px;
border-radius: 5px;
display: inline-block;
margin-top: 50px;
margin-bottom: 25px;
}

#changelog-content h3 {
color: var(--background-color);
background-color: var(--tertiary-color);
font-size: 1.5rem;
padding: 5px 15px;
border-radius: 3px;
display: inline-block;
margin-top: 10px;
margin-bottom: 15px;
}

* {
list-style-position: inside;
margin: 0px auto;
}

#changelog-content ul {
list-style-type: disc;
padding-left: 20px;
margin-bottom: 15px;
}

#changelog-content li {
margin-bottom: 5px;
}

#changelog-content p {
line-height: 1.6;
}

#changelog-content a {
color: var(--primary-color);
text-decoration: none;
}

#changelog-content a:hover {
text-decoration: underline;
}

/* Add responsive design */
@media (max-width: 768px) {
#changelog-content {
padding: 10px;
}

#changelog-content h2 {
font-size: 1rem;
}

#changelog-content h3 {
font-size: 0.9rem;
}
}
20 changes: 20 additions & 0 deletions docs/changelog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Effortless - Changelog</title>
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="/docs/docs.css" />
<link rel="stylesheet" href="changelog.css" />
<script src="templating.js"></script>
<script src="/docs/docs.js" type="module"></script>
<script src="changelog.js"></script>
<link rel="icon" type="image/png" href="../favicon.ico" />
</head>
<body>
<main>
<div id="changelog-content">Loading changelog...</div>
</main>
</body>
</html>
73 changes: 73 additions & 0 deletions docs/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
document.addEventListener("DOMContentLoaded", function () {
const changelogContainer = document.getElementById("changelog-content");
const changelogUrl =
"https://raw.githubusercontent.com/bboonstra/Effortless/main/CHANGELOG.md";

fetch(changelogUrl)
.then((response) => response.text())
.then((markdown) => {
const html = parseMarkdown(markdown);
changelogContainer.innerHTML = html;
updateChangelogIntro();
})
.catch((error) => {
console.error("Error fetching changelog:", error);
changelogContainer.innerHTML =
"<p>Error loading changelog. Please try again later.</p>";
});
});

function parseMarkdown(markdown) {
// Simple markdown parser
let html = "";
const lines = markdown.split("\n");
let inList = false;

lines.forEach((line) => {
if (line.startsWith("# ")) {
html += `<h1 class="feature">${line.slice(2)}</h1>`;
} else if (line.startsWith("## ")) {
html += `<h2 class="feature">${line.slice(3)}</h2>`;
} else if (line.startsWith("### ")) {
html += `<h3>${line.slice(4)}</h3>`;
} else if (line.startsWith("- ")) {
if (!inList) {
html += "<ul>";
inList = true;
}
html += `<li>${line.slice(2)}</li>`;
} else if (line.trim() === "") {
if (inList) {
html += "</ul>";
inList = false;
}
html += "<br>";
} else {
if (inList) {
html += "</ul>";
inList = false;
}
html += `<p>${line}</p>`;
}
});

return html;
}

function updateChangelogIntro() {
const paragraphs = document.querySelectorAll("#changelog-content p");

if (paragraphs.length >= 1) {
paragraphs[0].innerHTML = `All notable changes to this project will be documented on this page, imported from <a href="https://github.com/bboonstra/Effortless/blob/main/CHANGELOG.md" target="_blank">GitHub</a>.`;
}

if (paragraphs.length >= 2) {
paragraphs[1].innerHTML =
'The format is based on <a href="https://keepachangelog.com/en/1.0.0/">Keep a Changelog.</a>';
}

if (paragraphs.length >= 3) {
paragraphs[2].innerHTML =
'This project adheres to <a href="https://semver.org/spec/v2.0.0.html">Semantic Versioning.</a>';
}
}

0 comments on commit 1e1fbc9

Please sign in to comment.