Files
journal-d-un-formateur-en-2015/index.html
T

60 lines
1.4 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Journal d'un formateur en bootcamp</title>
<style>
body {
font-family: Arial, sans-serif;
color: black;
}
#journaux {
margin: 2rem;
}
</style>
<main id=journaux>
</main>
<script>
'use strict';
const afficheLaListeDesJournaux = () => {
const container = document.querySelector('#journaux');
fetch('https://api.daktary.com/yaf/journal-d-un-formateur-en-2015/tree/master/journaux')
.then(response => response.json())
.then(journaux => {
journaux.body.forEach(journal => {
const entreeDeJournal = MiseEnFormeDe(journal);
container.append(entreeDeJournal);
});
});
};
const MiseEnFormeDe = (journal) => {
const sectionJournal = document.createElement('section');
sectionJournal.innerHTML = journal.body;
var dateJournal = document.createElement('em');
dateJournal.textContent = new Date(journal.meta.date).toLocaleDateString('fr-FR', {year: 'numeric', month: 'long', day: 'numeric'});
sectionJournal.prepend(dateJournal);
var titreJournal = document.createElement('h1');
titreJournal.id = journal.meta.title;
titreJournal.textContent = journal.meta.title;
sectionJournal.prepend(titreJournal);
return sectionJournal;
}
afficheLaListeDesJournaux();
</script>
</html>