In this episode, we're kicking things off by setting up the ability to create a new note as soon as you land on the page. The intention is that if there aren't already any notes saved (we'll handle storage with localStorage later), we'll automatically generate a fresh, empty note for you to work with—the goal being you always have somewhere to start.
First, we make sure Alpine.js is loaded onto the page and then set up a store for our notes. This store holds an array (our notes list), and we define an init
method that will handle creating a new note if it's needed—no duplicating notes if one already exists!
We walk through writing the basic logic to generate unique note IDs (using the timestamp for now), and we give each note a structure: an ID, a title, and a body (both of which are empty strings to begin with). You get to see this data added to the page and visualized right away.
We also get a sneak peek at how we'll check if notes exist and only create a new one if no notes are present. The episode lays that foundation, setting things up for later when we'll make this persistent across sessions using localStorage.