You've already forked lnh-team.github.io
mirror of
https://github.com/LNH-team/lnh-team.github.io.git
synced 2026-01-09 16:27:49 -08:00
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
const buildButtons = document.querySelectorAll('.build-btn');
|
|
|
|
buildButtons.forEach(button => {
|
|
const buttonText = button.querySelector('.btn-text');
|
|
const buttonIcon = button.querySelector('.btn-icon');
|
|
const originalText = buttonText.textContent;
|
|
const originalIcon = buttonIcon.textContent;
|
|
const url = button.dataset.url;
|
|
|
|
// Encuentra el contenedor asociado al botón
|
|
const buildContent = button.parentElement.nextElementSibling;
|
|
|
|
button.addEventListener('click', () => {
|
|
const isOpen = buildContent.classList.toggle('show');
|
|
|
|
if (isOpen) {
|
|
buttonText.textContent = 'Close section';
|
|
buttonIcon.textContent = 'expand_less';
|
|
loadReadme(url, buildContent);
|
|
} else {
|
|
buttonText.textContent = originalText;
|
|
buttonIcon.textContent = originalIcon;
|
|
buildContent.innerHTML = ''; // opcional, limpia contenido al cerrar
|
|
}
|
|
});
|
|
});
|
|
|
|
// load and parse markdown file
|
|
async function loadReadme(url, container) {
|
|
try {
|
|
const response = await fetch(url);
|
|
if (!response.ok) throw new Error('Failed to fetch: ' + url);
|
|
const markdown = await response.text();
|
|
container.innerHTML = marked.parse(markdown);
|
|
} catch (error) {
|
|
container.innerHTML = `<p>Error loading README: ${error.message}</p>`;
|
|
}
|
|
}
|