async loadCards(project, title) { // 一旦カードをリセット if (this.bubble.firstChild) { this.bubble.removeChild(this.bubble.firstChild); } // カードを入れるリストを作成する const cards = document.createElement('div'); cards.classList.add('takker-cards','grid'); //console.log('loading cards...'); if (project !== scrapbox.Project.name) { const response = await fetch(`/api/pages/${project}/${title}`); if(!response.ok) return; const pages = await response.json().then(json => json.relatedPages.links1hop); pages.forEach(page => { const newCardText = createPageCard({ project: project, title: page.title, description: page.descriptions.join('\n'), imageUrl: page.image}); cards.insertAdjacentHTML('beforeend',newCardText); // cardを小さめにする const newCard = cards.lastElementChild; newCard.style.width = '120px'; newCard.style.height = '120px'; }); } else { [...document.getElementsByClassName('relation-label')] .filter(label => label.innerText === title) .forEach(label => { let card = label.nextSibling; while (card?.classList?.contains('page-list-item')) { const newCard = card.cloneNode(true); // cardを小さめにする newCard.style.width = '120px'; newCard.style.height = '120px'; cards.appendChild(newCard); card = card.nextSibling; } }); } this.bubble.appendChild(cards); }