Skip to content

Commit 7bdfe20

Browse files
author
Mabrur Habib
committed
modified: add wp rss in index.md
1 parent e22ce54 commit 7bdfe20

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

index.md

+26-9
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ title: Home
9191
</article>
9292
</div>
9393
</div>
94+
<header>
95+
<h2></h2>
96+
</header>
97+
<header>
98+
<h2>LAB WalkThrough</h2>
99+
</header>
100+
<div id="wordpress-feed"></div>
94101
</div>
95102
</section>
96103

@@ -99,7 +106,6 @@ title: Home
99106
const sections = document.querySelectorAll('section');
100107
sections.forEach(section => section.style.display = 'none');
101108

102-
// Function to show the selected section and hide others
103109
function showSection(selectedId) {
104110
sections.forEach(section => {
105111
if (section.id === selectedId) {
@@ -110,7 +116,6 @@ title: Home
110116
});
111117
}
112118

113-
// Add event listeners for navigation (modify this part according to your navigation setup)
114119
document.querySelectorAll('nav a').forEach(link => {
115120
link.addEventListener('click', function(e) {
116121
e.preventDefault();
@@ -119,25 +124,36 @@ title: Home
119124
});
120125
});
121126

122-
// Show the home section by default
123127
showSection('home');
124128

125-
// Medium RSS feed integration
126129
async function fetchMediumRSS() {
127130
const rssFeedUrl = 'https://medium.com/feed/@bibib';
128131
const rssToJsonUrl = `https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(rssFeedUrl)}`;
129132

130133
try {
131134
const response = await fetch(rssToJsonUrl);
132135
const data = await response.json();
133-
displayFeed(data);
136+
displayFeed(data, 'medium-feed');
137+
} catch (error) {
138+
console.error('Error fetching Medium RSS feed:', error);
139+
}
140+
}
141+
142+
async function fetchWordPressRSS() {
143+
const rssFeedUrl = 'https://nbsc7.wordpress.com/feed'; // Replace with your WordPress RSS feed URL
144+
const rssToJsonUrl = `https://api.rss2json.com/v1/api.json?rss_url=${encodeURIComponent(rssFeedUrl)}`;
145+
146+
try {
147+
const response = await fetch(rssToJsonUrl);
148+
const data = await response.json();
149+
displayFeed(data, 'wordpress-feed');
134150
} catch (error) {
135-
console.error('Error fetching RSS feed:', error);
151+
console.error('Error fetching WordPress RSS feed:', error);
136152
}
137153
}
138154

139-
function displayFeed(data) {
140-
const feedContainer = document.getElementById('medium-feed');
155+
function displayFeed(data, containerId) {
156+
const feedContainer = document.getElementById(containerId);
141157
const items = data.items;
142158

143159
items.forEach(item => {
@@ -150,5 +166,6 @@ title: Home
150166
}
151167

152168
fetchMediumRSS();
169+
fetchWordPressRSS();
153170
});
154-
</script>
171+
</script>

0 commit comments

Comments
 (0)