Changed around line 1
+ // Add smooth scrolling
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Add dark mode toggle
+ const darkModeToggle = document.createElement('button');
+ darkModeToggle.innerHTML = '🌓';
+ darkModeToggle.style.position = 'fixed';
+ darkModeToggle.style.bottom = '20px';
+ darkModeToggle.style.right = '20px';
+ darkModeToggle.style.padding = '10px';
+ darkModeToggle.style.borderRadius = '50%';
+ darkModeToggle.style.border = 'none';
+ darkModeToggle.style.cursor = 'pointer';
+
+ darkModeToggle.addEventListener('click', () => {
+ document.body.classList.toggle('dark-mode');
+ });
+
+ document.body.appendChild(darkModeToggle);
+
+ // Add estimated reading time
+ function addReadingTime() {
+ const articles = document.querySelectorAll('article');
+ articles.forEach(article => {
+ const text = article.textContent;
+ const words = text.trim().split(/\s+/).length;
+ const time = Math.ceil(words / 200);
+
+ const timeElement = document.createElement('div');
+ timeElement.classList.add('reading-time');
+ timeElement.textContent = `${time} min read`;
+
+ article.insertBefore(timeElement, article.firstChild);
+ });
+ }
+
+ document.addEventListener('DOMContentLoaded', addReadingTime);