Skip to content

Commit

Permalink
fix: links loading (#40)
Browse files Browse the repository at this point in the history
* fix: links loading

* fix: mehtod indentation
  • Loading branch information
fellrock authored Jan 13, 2025
1 parent c956576 commit 35c1cb7
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,24 @@ <h1>Felipe Moreira</h1>
const container = document.getElementById("links-container");

arquivos.forEach(arquivo => {
const caminhoArquivo = `${pasta}CV_FelipeMoreira${arquivo.sufixo}`;
const link = document.createElement("a");
link.href = caminhoArquivo;
link.innerHTML = `<img src="${arquivo.imagem}" width="20%" height="20%" alt="${arquivo.alt}">`;
container.appendChild(link);
fetch(pasta)
.then(response => response.text())
.then(data => {
// Usando uma expressão regular para encontrar o arquivo com o sufixo correspondente
const regex = new RegExp(`href="([^"]*${arquivo.sufixo})"`, "i");
const match = data.match(regex);

if (match && match[1]) {
const caminhoArquivo = match[1];
const link = document.createElement("a");
link.href = caminhoArquivo;
link.innerHTML = `<img src="${arquivo.imagem}" width="20%" height="20%" alt="${arquivo.alt}">`;
container.appendChild(link);
} else {
console.warn(`Arquivo com sufixo ${arquivo.sufixo} não encontrado.`);
}
})
.catch(error => console.error("Erro ao carregar os arquivos:", error));
});
}

Expand Down

0 comments on commit 35c1cb7

Please sign in to comment.