Neglected Words Stream
First stream in a while - exploring neglected words
Planted January 08, 2024
I’ve got two main tasks this week:
- Record some videos for a course
- Prepare teaching resources for upcoming courses
Today was the first day back in routine after the holidays and inspired by Charlie Coppinger I decided to stream to help keep my motivation up.
So, I pulled up my idea inbox and found a link to a list of words that deserve wider use.
Each word has its definition and use in a sentence and is structured like this:
It’s a static HTML page and I wanted to use Node to parse the HTML and then persist it to a file.
I used Cheerio to be able to access get the data and parse it:
fetch
is now a Node global now and so didn’t need any import.
With the text of the body, we instantiate Cheerio with the text and assign it to a variable. You can call the variable anything you want but there is a general convention to use $
. This is a reminder to those of us who have used jQuery before.
You can now use this function to access elements:
The returned element has a .each()
method that allow you to loop over everything that matches the query.
Within each li then, we find the word, definition and sentence which are all identified by class. We then append this to an array with an id.
For the rest of the stream, we built a fastify API to serve the data which was a lot of fun.
I think I might stream tomorrow and make a game using the data. I’ve got a React course coming up in a few weeks, so I’ll probably build in React.
If you’re around at 2pm GMT, I’ll see how much I can get done in an hour.
Here’s the Git repo of what we’ve been working on.
I can’t decide whether it’s worth putting the video of the stream up on YouTube or not.