feat: Establish CI pipeline, pre-commit hooks, and code quality linting for improved developer experience.

This commit is contained in:
2026-03-11 20:51:35 +03:00
parent c0e261c2ed
commit 187c8eb078
49 changed files with 208356 additions and 1216 deletions
+41 -39
View File
@@ -1,50 +1,52 @@
document.addEventListener('DOMContentLoaded', () => {
// Select all <pre> elements that contain code blocks
const preBlocks = document.querySelectorAll('pre');
// Select all <pre> elements that contain code blocks
const preBlocks = document.querySelectorAll('pre');
const copyIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>';
const checkIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>';
const copyIcon =
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"/><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"/></svg>';
const checkIcon =
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 6 9 17l-5-5"/></svg>';
preBlocks.forEach((pre) => {
// Create the copy button
const button = document.createElement('button');
button.innerHTML = copyIcon;
button.className = 'copy-code-btn';
button.setAttribute('aria-label', 'Copy code');
button.setAttribute('title', 'Copy code');
preBlocks.forEach((pre) => {
// Create the copy button
const button = document.createElement('button');
button.innerHTML = copyIcon;
button.className = 'copy-code-btn';
button.setAttribute('aria-label', 'Copy code');
button.setAttribute('title', 'Copy code');
// Add the button to the <pre> block
// Assuming pre is position relative in CSS
pre.appendChild(button);
// Add the button to the <pre> block
// Assuming pre is position relative in CSS
pre.appendChild(button);
button.addEventListener('click', async () => {
// Find the <code> element within the <pre>
const code = pre.querySelector('code');
if (!code) return;
button.addEventListener('click', async () => {
// Find the <code> element within the <pre>
const code = pre.querySelector('code');
if (!code) return;
// Get the text content, removing any leading/trailing whitespace
const text = code.innerText;
// Get the text content, removing any leading/trailing whitespace
const text = code.innerText;
try {
// Wait for the clipboard API
await navigator.clipboard.writeText(text);
try {
// Wait for the clipboard API
await navigator.clipboard.writeText(text);
// Add visual feedback
button.innerHTML = checkIcon;
button.classList.add('copied');
button.setAttribute('aria-label', 'Copied');
button.setAttribute('title', 'Copied!');
// Add visual feedback
button.innerHTML = checkIcon;
button.classList.add('copied');
button.setAttribute('aria-label', 'Copied');
button.setAttribute('title', 'Copied!');
// Revert back after 2 seconds
setTimeout(() => {
button.innerHTML = copyIcon;
button.classList.remove('copied');
button.setAttribute('aria-label', 'Copy code');
button.setAttribute('title', 'Copy code');
}, 2000);
} catch (err) {
console.error('Failed to copy code: ', err);
}
});
// Revert back after 2 seconds
setTimeout(() => {
button.innerHTML = copyIcon;
button.classList.remove('copied');
button.setAttribute('aria-label', 'Copy code');
button.setAttribute('title', 'Copy code');
}, 2000);
} catch (err) {
console.error('Failed to copy code: ', err);
}
});
});
});