Article Of The Day
- 3 Devlogs
- 12 Total hours
A random article generator! One day, one article.
A random article generator! One day, one article.
I have expanded support from Wikipedia to more sources like Wired, BBC, The Verge, etc… It took a while because I had to learn how to use npm and the rss-parser library.
response.status.
I added an open article button which opens the random article on click. I learned how to implement this through Javascript by using article.content_urls.desktop.page; to get the article url and then open the article on click using window.open(url, "_blank");, and an event listener on the open article button.
I also added the current date at the top of the title using date.toLocaleDateString.
I styled the buttons to slightly glow on hover and sink into the screen (inset box-shadow) on click.
I started with Astro but after learning astro for about 1 hour, I realized that it was overkill for what I was trying to do. So instead I swapped to HTML, CSS, and JS (although, I’ll probably try programming it in Astro when I get the html/css/js version to work).
I spent around 15 minutes looking for colors, fonts, and a custom cursor icon for the site. I settled with the cute coffee bean icon which you can see in the image!
The rest of the time was spent adding the styles to styles.css, setting up the HTML to work with the Javascript code, and implementing API fetch functions. The Javascript kinda works, but I haven’t linked it with the button yet, so it only loads the article on page refresh. Also, the JS only works with Wikipedia API for now, but more sites are going to be added very soon.