87 lines
2.0 KiB
HTML
87 lines
2.0 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;
|
|
width: 30rem;
|
|
text-align: justify;
|
|
line-height: 1.2rem;
|
|
}
|
|
|
|
#journaux blockquote {
|
|
border-left: 10px solid lightgrey;
|
|
font-size: 1.2rem;
|
|
font-weight: bolder;
|
|
font-style: italic;
|
|
}
|
|
|
|
#journaux p {
|
|
margin: 1.2rem;
|
|
text-indent: 1.2rem;
|
|
}
|
|
|
|
#journaux h1 {
|
|
margin: 1.2rem 0 0 0;
|
|
padding: 2rem 0 1rem 0;
|
|
border-top: 1px solid black;
|
|
}
|
|
#journaux time {
|
|
display: block;
|
|
text-align: right;
|
|
font-style: italic;
|
|
}
|
|
|
|
</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('time');
|
|
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>
|