summaryrefslogtreecommitdiff
path: root/markdown.js
blob: 3dac757c0302687a8148b3e9826903e2f486f5e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function loadMarkdownFile(fileName) {
  fetch(`/assets/md/${fileName}`)
    .then(response => response.text())
    .then(text => {
      document.getElementById('markdown').innerHTML = convertMarkdownToHTML(text);
      addBlankTargetToLinks();
    })
    .catch(error => {
      console.error('Error loading Markdown file:', error);
    });
}

function convertMarkdownToHTML(markdown) {
  return marked.parse(markdown);
}

function addBlankTargetToLinks() {
  const links = document.querySelectorAll('a');
  links.forEach(link => {
    link.setAttribute('target', '_blank');
  });
}