41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import {
|
|
getAllLines
|
|
} from "./lines-rest-api";
|
|
|
|
|
|
async function createCard(title, description, image) {
|
|
const cardContainer = document.querySelector('.images');
|
|
|
|
if (image === "") {
|
|
image = "img/korotysh.png"
|
|
}
|
|
|
|
const cardItem =
|
|
`
|
|
<button class="prev" style="background-color: #03001F; border: none; margin-left: 1%">
|
|
<a href="Film.html">
|
|
<div class="card text-bg-dark" style="max-width: 20rem">
|
|
<img src="${image}" class="card-img" alt="превью">
|
|
<div class="card-img-overlay">
|
|
<h5 class="card-title">${title}</h5>
|
|
<p class="card-text">${description}</p>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
</button>
|
|
`;
|
|
|
|
cardContainer.insertAdjacentHTML('beforeend', cardItem);
|
|
}
|
|
|
|
async function createCards() {
|
|
const data = await getAllLines();
|
|
console.log(data)
|
|
data.forEach(item => {
|
|
createCard( item.title, item.description, item.image);
|
|
});
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
createCards();
|
|
}); |