Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ // Smooth scroll for anchor links
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function(e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Lazy load images if added later
+ if ('IntersectionObserver' in window) {
+ const lazyObserver = new IntersectionObserver((entries) => {
+ entries.forEach(entry => {
+ if (entry.isIntersecting) {
+ const img = entry.target;
+ img.src = img.dataset.src;
+ lazyObserver.unobserve(img);
+ }
+ });
+ });
+
+ document.querySelectorAll('img[data-src]').forEach(img => {
+ lazyObserver.observe(img);
+ });
+ }
+
+ // Add subtle animation to post cards
+ const posts = document.querySelectorAll('.post');
+ posts.forEach((post, i) => {
+ post.style.transitionDelay = `${i * 0.05}s`;
+ });
+
+ // Dynamic meta tags for social sharing
+ const updateMetaTags = () => {
+ const title = document.title;
+ const description = document.querySelector('meta[name="description"]')?.content ||
+ document.querySelector('article')?.textContent.trim().substring(0, 160) + '...';
+
+ // Update Open Graph tags
+ document.querySelector('meta[property="og:title"]')?.setAttribute('content', title);
+ document.querySelector('meta[property="og:description"]')?.setAttribute('content', description);
+ };
+
+ updateMetaTags();
+ });
+
+ // Simple theme switcher if needed later
+ function toggleTheme() {
+ document.body.classList.toggle('dark-theme');
+ }