41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
// Directory Page Card Structure Fix
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Function to check and fix article card structure
|
|
function fixArticleCards() {
|
|
const articlesGrid = document.querySelector('.articles-grid');
|
|
if (!articlesGrid) return;
|
|
|
|
// Get all article cards
|
|
const cards = articlesGrid.querySelectorAll('.article-card');
|
|
|
|
cards.forEach(card => {
|
|
// Check if card is an anchor tag
|
|
if (card.tagName.toLowerCase() !== 'a') return;
|
|
|
|
// Check if card has proper structure
|
|
const hasImage = card.querySelector('.article-card-image');
|
|
const hasContent = card.querySelector('.article-card-content');
|
|
|
|
if (!hasImage || !hasContent) {
|
|
console.warn('Article card structure issue detected:', card);
|
|
|
|
// Try to fix by finding orphaned content
|
|
const nextSibling = card.nextElementSibling;
|
|
if (nextSibling && nextSibling.classList.contains('article-card-content')) {
|
|
// Move the content inside the card
|
|
card.appendChild(nextSibling);
|
|
}
|
|
}
|
|
|
|
// Ensure card has proper display properties
|
|
card.style.display = 'flex';
|
|
card.style.flexDirection = 'column';
|
|
});
|
|
}
|
|
|
|
// Run the fix
|
|
fixArticleCards();
|
|
|
|
// Also run after a short delay in case of dynamic content
|
|
setTimeout(fixArticleCards, 100);
|
|
}); |