Proponuję użycie <template> i tablicy asocjacyjnej. Wtedy edytujesz dołączany plik (w tym przykładzie: gallery-item.js) i wysyłasz na serwer.
przykład
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="utf-8" />
<style>
.gallery-item a:link {
text-decoration: none;
}
.gallery-item .card {
width: 500px;
height: 150px;
margin: 0.5em;
background-position: center center;
background-repeat: no-repeat;
}
.gallery-item .card .info {
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.35);
}
.gallery-item .card p {
padding: 0.5em 1em;
margin: 0.25em;
}
.gallery-item .card p:first-child {
font: 900 1.5em tahoma;
color: yellow;
}
.gallery-item .card p:not(:first-child, :last-child) {
font: 500 1.05em arial;
color: white;
}
.gallery-item .card p:last-child {
font: 700 1em monospace;
color: white;
}
</style>
</head>
<body>
<div class="gallery-item kolonia-mala"></div>
<template id="gallery-item-tmpl">
<a href="{{href}}">
<div class="card" style="background-image: url({{background_image}})">
<div class="info">
<p>{{title}}</p>
<p>{{description}}</p>
<p>{{date}}</p>
</div>
</div>
</a>
</template>
<script src="gallery-item.js?v=1.0"></script>
<script>
let template, gallery;
window.addEventListener('DOMContentLoaded', load);
function load() {
template = document.querySelector('#gallery-item-tmpl');
gallery = document.querySelector('.gallery-item');
let html_cards = '';
for (item of gallery_item) {
let html_card = template.innerHTML.replace('{{background_image}}', item.background_image);
html_card = html_card.replace('{{title}}', item.title);
html_card = html_card.replace('{{href}}', item.href);
html_card = html_card.replace('{{description}}', item.description);
html_card = html_card.replace('{{date}}', item.date);
html_cards += html_card;
}
gallery.innerHTML = html_cards;
}
</script>
</body>
</html>
gallery-item.js
const gallery_item = [
{
'background_image':'https://picsum.photos/500/150/?random=1',
'href':'https://forum.pasja-informatyki.pl/user/gatka84',
'title':'Tytuł 1',
'description':'Opis 1',
'date':'16-12-2021'
},
{
'background_image':'https://picsum.photos/500/150/?random=2',
'href':'https://forum.pasja-informatyki.pl/user/gatka84',
'title':'Tytuł 2',
'description':'Opis 2',
'date':'15-12-2021'
},
{
'background_image':'https://picsum.photos/500/150/?random=3',
'href':'https://forum.pasja-informatyki.pl/user/gatka84',
'title':'Tytuł 3',
'description':'Opis 3',
'date':'17-12-2021'
}
]
P.S. Dlaczego taki zapis?
gallery-item.js?v=1.0
Tu znajdziesz wskazówki